This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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.
I agree. Here's the link:
subject: getresource path
Similar Threads
Getting rid of Java Icon on the upper left hand corner
Creating a Self-Contained Jar
need help troublshooting
problem in setting background image of jpanel
getClass().getClassLoader().getResource(path) always return null, even when the path is correct