This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java -jar" Watch "java -jar" New topic

java -jar

Fernando Matias Valadao

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/".
Therefore, my app.jar looks like this:


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

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

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


"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 !
Fernando Matias Valadao

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 Matias Valadao

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

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

Thank you very much!

subject: java -jar
Similar Threads
how can i put configurations files outside war file
Help Reading file in Axis webapp
creating jar file with properties file
accessing resources from a jar file.
JAR + Properties