Java classpath and config file

Posted by user1228291 on Stack Overflow See other posts from Stack Overflow or by user1228291
Published on 2012-02-23T12:16:50Z Indexed on 2012/06/25 9:16 UTC
Read the original article Hit count: 144

Filed under:
|
|

I'm having some trouble finding a config file with classpath.

I use :

InputStream stream = myclass.class.getResourceAsStream("properties.file");

The properties.file is located under config directory.

When running the program with eclipse, it works. I just added config folder in the classpath in the launch configuration.

But If I want to run the exported jar like this :

java -jar -cp C:\project\lib;C:\project\config myclass.jar

I get the oh wonderful java.lang.NullPointerException because it can't find the file.

This sounds classic and stupid but I can't find a clue. What does eclipse do that I don't ?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about eclipse