Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

740 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