aspose file tools*
The moose likes Beginning Java and the fly likes ClassLoader.getSystemResourceAsStream() returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ClassLoader.getSystemResourceAsStream() returning null" Watch "ClassLoader.getSystemResourceAsStream() returning null" New topic
Author

ClassLoader.getSystemResourceAsStream() returning null

mahavir swami
Greenhorn

Joined: Sep 18, 2009
Posts: 13
I am using eclipse ide for my java projects
and in eclipse there is an option to export the project as a runnable jar file
and it creates MINIFEST.MF file which has all the information about the main method and other jar's used by the code

and in my code i am using


now when i run my code using eclipse , it finds abc.properties file
but when i am running through command prompt
java -jar <jar-file-name> args




returns null

now i believe there is some class path problem
i have set the classpath in my environmental variables but still cannot find above file from class path

please help

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
Don't set the classpath as an environment variable.

Make sure the file is in the correct location. You will have a current directory, where you can invoke your classes with

java foo.bar.MyClassWithMainMethod

That is the sort of "root" for your package structure. Try copying the file into that location and see whether that improves things. If that doesn't help, don't know, sorry.
mahavir swami
Greenhorn

Joined: Sep 18, 2009
Posts: 13
I moved my properties file at the level where META-INF folder is there in jar file and
my code worked, i mean ClassLoader could find the file there
but if i want the file to be any where on the machine and the path will be set in classpath
then how do we achive that?
 
Don't get me started about those stupid light bulbs.
 
subject: ClassLoader.getSystemResourceAsStream() returning null