• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems setting classpath

 
Erika Carvajal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading a property file on my app that is on the resources directory but the application doesnt found the file.
The only way to read the file if i put it on the eclipse directory such is very rare. I hope someone can suggest something



i also tried "/resources/messages.properties" but didnt work

thanks.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileInputStream doesn't look on the classpath for the file it open. In the first case, you provide a relative path, so it looks in the current working directory. (Probably eclipse when you're testing.) In the second example, you provide an absolute path, so it will look for the file exactly there in a directory called resources off your root directory.

You may want to use a ResourceBundle instead. That actually will use the classpath, and is how files named messages.properties are usually loaded. Check out the Javadoc and come back if you have any problems.
 
Erika Carvajal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I finally got with a solution:



It looks on the resources directory.

Thanks for your comments.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!