Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

loading ImageIcon from jar

843805Jan 8 2007 — edited Jan 13 2008
I have an application (with imageicons) jarred.
The application at first didn't load the images. After reading in topics here I understanded that this should be the right implementation for reading image icons out of jars:
unDoButton = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("img/vorige.jpg")));
		reDoButton = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("img/volgende.jpg")));
		treeViewButton = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("img/mappen.jpg")));
		weergaveButton = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("img/weergave.jpg")));
		bovenLiggendeMapButton = new JButton(new ImageIcon(this.getClass().getClassLoader().getResource("img/bovenLiggendeMap.jpg")));
After jarring the application, and running the jar file, nothings happens.
Changing it back to:
unDoButton = new JButton(new ImageIcon("img/vorige.jpg"));
..the application works, only the icons aren't loaded.

Anyone suggestions?

Greets,
Sjoerd
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2008
Added on Jan 8 2007
17 comments
1,204 views