Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Jar and Policy file

Posted on 2004-09-10
9
Medium Priority
?
303 Views
Last Modified: 2008-02-26
Hi All,
      Earlier we used to execute our application using the run.bat file containing the following command:
java -classpath .\lib -D"java.ext.dirs=.\lib"
-Djava.security.policy==client.policy com.sciatl.svt.ui.Login

      Obviously it opens up a dos console which we are trying to avoid in the current release and the only option is to package all the class file in a jar file. With the help of the manifest file i am launching the Login class.

Here is the manifest file:

Manifest-Version: 1.2
Created-By: 1.3.1 (Sun Microsystems Inc.)
Main-Class: com.sciatl.svt.ui.Login
Class-Path: lib/classes12.jar lib/ejb.jar lib/jaas.jar lib/jaxb-rt-1.0-ea.jar lib/jta.jar lib/oc4j.jar lib/oc4jclient.jar

Now i don't know how to specify the client.policy file in my manifest file or can i specify my policy file somewhere?

Kindly let me know if you have any suggestions or ideas.

Thanks & Regards,
Prem.
0
Comment
Question by:PRAC
9 Comments
 
LVL 6

Expert Comment

by:expertmb
ID: 12024927
0
 
LVL 92

Expert Comment

by:objects
ID: 12024931
don't think you can sorry
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12024982
You can avoid the console window by invoking javaw in stead of java
I don't know the answer about the policy file.
;JOOP!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:PRAC
ID: 12025085
Even if i use javaw instead of java, when i double click my run.bat the dos console window comes up.
0
 

Author Comment

by:PRAC
ID: 12025187
I am able to ignore the dos window by adding "start" before javaw in my run.bat file. Now my run.bat contains:

start javaw -classpath .\lib -D"java.ext.dirs=.\lib"
-Djava.security.policy==client.policy com.sciatl.svt.ui.Login

Thanks & Regards,
Prem.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12025331
I presume you run on Windows98 or ME : indeed that's a bug.

;JOOP!
0
 

Author Comment

by:PRAC
ID: 12025348
The OS is Windows XP.
0
 
LVL 1

Accepted Solution

by:
helloexpert earned 375 total points
ID: 12026414
try this

i.e, create an entry for the security policy in the manifest file as
Security-Policy=your file path

then in the java code, get the security policy like this

         JarFile jar = new JarFile(path);
          Manifest mfest = jar.getManifest();
          Attributes attr = mfest.getMainAttributes();
          String cp = attr.getValue("Security-Policy");

then use System.setProperty(..) to set the new policy file.

hope that helps.
0
 

Author Comment

by:PRAC
ID: 12033781
I am able to set my policy file using the following line in my Login class:
System.setProperty("java.security.policy", "client.policy");

Thanks to "helloexpert".
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question