This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes java -jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "java -jar" Watch "java -jar" New topic
Author

java -jar

Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Hi, buddies!
I've packaged my Java app into a runnable jar file, which beyound the .class files also include a "conf/conf.properties".
Therefore, my app.jar looks like this:

com/enterprise/*.class
META-INF/MANIFEST.MF
conf/conf.properties

The problem is that my app runnable class can't find the "conf/conf.properties". The error is "The system cannot find the path specified".

If I take it out and put it in a directory ("conf/conf.properties"), everything works just fine.

Does it mean I have to put the conf/conf.properties outside the .jar file? Or am I doing some kind of ?
Thanks in advance.

Fernando


"In the case of a nuclear attack, the protection of our records is essential, if this country is to carry on its economy and maintain our way of life."
Arnaud Burlet
Ranch Hand

Joined: Oct 08, 2004
Posts: 31
Hello there,

the last time I needed something like that, I used that piece of code :


Can't remember another way ... hope that one is ok for you !
Arnaud
Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Thank you for replying, Arnaud, but are you sure it works?
I have tried it the way you posted but the input stream is empty.
Do you have any idea why this is happening?

Fernando
Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Hi, Arnaud!
It worked!!! I did it this way:

...
InputStream configStream = ClassLoader.getSystemClassLoader().getResourceAsStream("conf/conf.properties");
Properties confFile = new Properties();
try {
confFile.load(configStream);
...

Thank you very much!


Fernando
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: java -jar
 
Similar Threads
JAR + Properties
creating jar file with properties file
accessing resources from a jar file.
Help Reading file in Axis webapp
how can i put configurations files outside war file