Solved

Netbeans Java Classpath, Accessing property file outside package in seperate directory

Posted on 2013-01-04
3
447 Views
Last Modified: 2013-01-05
I am trying to move my resource file out of my jar file to an independent conf folder and appear to be having classpath issues. Initially, I would like to get running in my Netbeans project and have changed the classpath from the project properties.libraries.run tab. From here, I selected the Add jar/Folder and provided an absolute path with the absolute path selected. Is this correct? Why will this not work within Netbeans 7.2.1?

String resource_file = "project_config.xml";
InputStream in = this.getClass().getResourceAsStream(resource_file);
 if (in == null) {
        throw new IOException("Error reading resource file:" + resource_file);
  }
0
Comment
Question by:1240
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 350 total points
ID: 38745491
You can't really treat resources like that. Normally, they should not be outside a jar, unless you need to also write to them, in which case, they should be treated and addressed as files.
0
 

Author Closing Comment

by:1240
ID: 38745681
Thanks for the info
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38746715
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now