Unable to load Properties file from JAR file

M

Michael

Hi,

I have JARred up my Java app program so that it can be run by
double-clicking it. The problem now is that I can't run the Java app
as it can't find the PROPERTIES file in the JAR.

In my project, I included the folder "properties" where I store all
the properties files and I checked the folder exists in the JAR, but
somehow it is not able to locate it.

In my source file that tries to load the properties is shown below:

private final String DEFAULT_PROPERTY_FOLDER = "properties/";
private final String DEFAULT_NODE_PROPERTY_FILE =
"defaultNode.properties";

filePath = filePath = DEFAULT_PROPERTY_FOLDER +
DEFAULT_NODE_PROPERTY_FILE;

try {
inNode = new FileInputStream(filePath);
} catch (FileNotFoundException ex) {
System.out.println("[ " + propertiesFile + " ]" + " not
found.");
}

try {
load(inNode);
} catch (IOException ex1) {
System.out.println("Error loading up the default
properties file.");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top