wood burning stoves 2.0*
The moose likes Java in General and the fly likes a icon path in a java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "a icon path in a java program" Watch "a icon path in a java program" New topic
Author

a icon path in a java program

Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147

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

Joined: Aug 11, 2011
Posts: 440

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 ?


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
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

Joined: Oct 27, 2005
Posts: 19655
    
  18

Please re-read Darryl's post.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a icon path in a java program
 
Similar Threads
Retrieve system icons
B&S free icons use
How can I change the logo?
Where do I put icons in a Netbeans 5.5.1 project?
Loading Icon from Swing jar