How do I determine the application .jar file used via "java -jar"?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Donnie_Hale
Posted On:   Friday, December 28, 2001 08:29 AM

Say I run a program via: java -jar app.jar I need to get the URL of app.jar. If I pass some info as an application parameter, I can do it. However, I'd like to be able to do it without having to rely on an application parameter. I see that it's in the java.class.path system property. And, at least for me, if I run "java -jar -cp other.jar app.jar", "other.jar" does not show up in the java.class.path property. I'm not sure if that's documented or expected behavior or not. If so, then I could just get it from there. Any ideas? Thanks, Donnie    More>>

Say I run a program via:


java -jar app.jar


I need to get the URL of app.jar. If I pass some info as an application parameter, I can do it. However, I'd like to be able to do it without having to rely on an application parameter.


I see that it's in the java.class.path system property. And, at least for me, if I run "java -jar -cp other.jar app.jar", "other.jar" does not show up in the java.class.path property. I'm not sure if that's documented or expected behavior or not. If so, then I could just get it from there.


Any ideas?


Thanks,


Donnie

   <<Less

Re: How do I determine the application .jar file used via "java -jar"?

Posted By:   Donnie_Hale  
Posted On:   Friday, December 28, 2001 10:13 AM

According to http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html, if you use the "-jar" option, the .jar file is the source of all user classes and other user classpath settings are ignored.


So I should be able to read that one entry from java.class.path and then get the URL from that.


Donnie

About | Sitemap | Contact