Solved

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

Posted on 2013-01-04
3
446 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
Comment Utility
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
Comment Utility
Thanks for the info
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

762 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

6 Experts available now in Live!

Get 1:1 Help Now