Getting a icon from jar or system directory

Posted on 2006-05-28
Medium Priority
Last Modified: 2010-03-31
ImageIcon icon = new ImageIcon(iconPath) is the way I use to gat an icon from a system folder, assuming that iconPath maybe something like "icons//myicon.gif" relative to the root path of application. It works, but when I embedd the icons dir in a jar an try to get it as resource I'm unable to get as system file or the contraty....
Question by:rubentrancoso
  • 2
  • 2
LVL 86

Accepted Solution

CEHJ earned 2000 total points
ID: 16780497
I would put an


entry at the root of your jar. You can then do

ImageIcon icon = new ImageIcon(getClass().getResource("/images/myicon.gif"));

LVL 86

Expert Comment

ID: 16780712

A suggestion:

"Creating bar/popup menus was never so easy and elegant. From a simple XML file with bar/popup menu definitions and a line of code it's possible to build full menus with all the functionality these components ever need to have."

Author Comment

ID: 16780769
right! :)

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question