Solved

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

Posted on 2013-01-04
3
448 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 85
print map entry 34 67
replace a word with other 1 44
hibernate insert example 13 28
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

776 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