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
Author

getresource path

Jorge Sereno
Greenhorn

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

looks for.

Thankx
Jorge Sereno
Greenhorn

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

Example.
A structure like
src
--pt.ts1
----Main.java
--pt.ts2
----MainTest.java
resources
--file.txt

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

Joined: Jun 19, 2010
Posts: 825
    
    5

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: http://aspose.com/file-tools
 
subject: getresource path
 
Similar Threads
Getting rid of Java Icon on the upper left hand corner
Creating a Self-Contained Jar
need help troublshooting java.net.MalformedURLException
problem in setting background image of jpanel
getClass().getClassLoader().getResource(path) always return null, even when the path is correct