Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do i find the filename of the class / jar file thats being executed?

807580Aug 7 2010 — edited Aug 12 2010
Hi

Anyone know how to find the name of the class / jar file thats being executed and store it in a string?
For example if a doubleclick a jarfile named myjarfile.jar i would like to print out "myjarfile.jar"
And same for classes if i have a class naamed myclass.class i would like it to print out "myclass.class"

ive tried
System.out.println( this.getClass().getResource(".") );
System.out.println( System.getProperty("user.dir") );
but they only give me the working directory

somewhere in the jvm it should say where the bytedata was loaded from.

Thanks for any kind of help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 9 2010
Added on Aug 7 2010
16 comments
1,168 views