wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes getresource path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getresource path" Watch "getresource path" New topic

getresource path

Jorge Sereno

Joined: Jun 30, 2012
Posts: 9
Where is the path the method

looks for.

Jorge Sereno

Joined: Jun 30, 2012
Posts: 9
how can i define the global path for the method looks for?

A structure like

when i use somewhere in the app looks for the path resources/file.txt.
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

First of all, I would suggest you read HowToAskQuestionsOnJavaRanch FAQ.

As for your problem, to access root directory (package) in src you add forward slash at the beginning of your String. Further it's the matter of your package structure:

Also note that Java is case sensitive so there are no methods getclass() or getresource().

The quieter you are, the more you are able to hear.
It is sorta covered in the JavaRanch Style Guide.
subject: getresource path
Similar Threads
getClass().getClassLoader().getResource(path) always return null, even when the path is correct
need help troublshooting java.net.MalformedURLException
Getting rid of Java Icon on the upper left hand corner
Creating a Self-Contained Jar
problem in setting background image of jpanel