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 access files outside a .jar file netbeans project

807601Feb 25 2008 — edited Mar 3 2008
Hi, i need to access a file outside a built project inside netbeans. Ideally i would like this file next to the .jar file as myapp.properties. If possible i would like it so that when i am compiling and running the project in netbeans the file can be with the class files or something along those likes. Either way it would be nice to have different code for built projects and just running them outside a jar.

Heres what i got so far
properties = new Properties();
            InputStream in = this.getClass().getResourceAsStream("applications.properties");
            properties.load(in);
            in.close();
this only works if the file is next to the classes. (think thats called the classpath ? )

Thanks for any replies!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2008
Added on Feb 25 2008
21 comments
1,397 views