Skip to Main Content

New to Java

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 to get the directory of a file within an executable jar?

807601Jan 3 2008 — edited Jan 4 2008
I want to be able to create a new File() with a .xml that is within a folder in my executable jar. I have tried getting the directory with
String.valueOf(getClass().getResource("/data/info.xml")).substring(6).trim()
which works if i use command prompt but does not work when i use the excutable. Any ideas are welcome :D

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 1 2008
Added on Jan 3 2008
7 comments
533 views