• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a icon path in a java program

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please re-read Darryl's post.
reply
    Bookmark Topic Watch Topic
  • New Topic