• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassLoader.getSystemResourceAsStream() returning null

 
mahavir swami
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic