wood burning stoves 2.0*
The moose likes Java in General and the fly likes java -jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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://aspose.com/file-tools
 
subject: java -jar