• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a icon path in a java program

 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have an icon is in other project folder named icons.
How do I set the path as below:

private String ICON_PATH = "....../icons/icon_name.png";

Thanks for your help.
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings ,

Personally I dont like the fact of putting hard coded paths inside my java classes. I put all such paths in a properties file and read them from the properties file. Secondly what problem are you facing ? I mean you specified the path as "/path/to/icons/icon_name.png" and java couldnt find the file ( threw a FileNotFoundException) or there is some other issue ?
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial section on Loading Images Using getResource says it better than I ever could, along with illustrations.

If by 'other project folder' you mean that the image file resides in another project of your IDE, you need to add that project or its .jar as a library. Note that projects are a feature of certain IDEs and are not a part of the Java programming language.
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saif Asif wrote:Greetings ,

Personally I dont like the fact of putting hard coded paths inside my java classes. I put all such paths in a properties file and read them from the properties file. Secondly what problem are you facing ? I mean you specified the path as "/path/to/icons/icon_name.png" and java couldnt find the file ( threw a FileNotFoundException) or there is some other issue ?


I have to get the icon that is under another project folder named icons folder.
If you know how to get it, please let me know.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please re-read Darryl's post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic