Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8220489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:32:05+00:00 2026-06-07T13:32:05+00:00

When I try to run my newly finished program from my desktop as a

  • 0

When I try to run my newly finished program from my desktop as a .jar file it gets stuck while running on the “Please Wait…” screen I have to indicate my program is still loading. At the same time, running it from Eclipse IDE it works perfectly fine! Running

java -jar C:\path\to\my\jar\file.jar

results in an Error that looks like:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
    at ...
Caused by java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:205)...

Yes, I know java.lang.ExceptionInInitializerError means there was an Exception while loading some static variable in a class. The error was a NullPointerException in an ImageIcon, meaning one of my (many) static ImageIcon‘s was given a null URL to load. I used getClass().getResource("someFile") which returns null if nothing was found. Yes, I have spelled all the image names correctly. Here is my code:

public static final ImageIcon cloud = new ImageIcon(SomeClass.class.getResource("cloud.png"));
public static final ImageIcon whiteFlower = new ImageIcon(SomeClass.class.getResource("white_flower.png"));
public static final ImageIcon pinkFlower = new ImageIcon(SomeClass.class.getResource("pink_flower.png"));
public static final ImageIcon redFlower = new ImageIcon(SomeClass.class.getResource("red_flower.png"));
public static final ImageIcon blueFlower = new ImageIcon(SomeClass.class.getResource("blue_flower.png"));
public static final ImageIcon bird1 = new ImageIcon(SomeClass.class.getResource("bird_animation\\bird1.png"));
public static final ImageIcon bird2 = new ImageIcon(SomeClass.class.getResource("bird_animation\\bird2.png"));
public static final ImageIcon bird3 = new ImageIcon(SomeClass.class.getResource("bird_animation\\bird3.png"));
public static final ImageIcon bird4 = new ImageIcon(SomeClass.class.getResource("bird_animation\\bird4.png"));
public static final ImageIcon bird5 = bird4;
public static final ImageIcon bird6 = bird3;
public static final ImageIcon bird7 = bird2;
public static final ImageIcon bird8 = bird1;
public static final ImageIcon moon = new ImageIcon(SomeClass.class.getResource("moon.png"));
public static final ScaledImageIcon star = new ScaledImageIcon(SomeClass.class.getResource("star.png"), 0.225/*average of 0.15 and 0.3*/);
public static final PixelResizeImageIcon squirrel = new PixelResizeImageIcon(SomeClass.class.getResource("squirrel.gif"/*"bunny.gif"*/), 1.5);
public static final ScaledImageIcon whiteBird1 = new ScaledImageIcon(SomeClass.class.getResource("bird_animation\\white1.png"), 1);
public static final ScaledImageIcon whiteBird2 = new ScaledImageIcon(SomeClass.class.getResource("bird_animation\\white2.png"), 1);
public static final ScaledImageIcon whiteBird3 = new ScaledImageIcon(SomeClass.class.getResource("bird_animation\\white3.png"), 1);
public static final ScaledImageIcon whiteBird4 = new ScaledImageIcon(SomeClass.class.getResource("bird_animation\\white4.png"), 1);
public static final ScaledImageIcon whiteBird5 = new ScaledImageIcon(SomeClass.class.getResource("bird_animation\\white5.png"), 1);
public static final ScaledImageIcon whiteBird6 = whiteBird4;
public static final ScaledImageIcon whiteBird7 = whiteBird3;
public static final ScaledImageIcon whiteBird8 = whiteBird2;
public static final ScaledImageIcon whiteBird9 = whiteBird1;

And here is my project:

Birthday Card Project Image

Everything is working perfectly fine in Eclipse, but when I export it to a .jar file and run it with java -jar it gives me an error! Can somebody help please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:32:07+00:00Added an answer on June 7, 2026 at 1:32 pm

    Check that all the images are in the jar, and use forward slashes rather than backslashes for resource paths:

    SomeClass.class.getResource("bird_animation/white1.png")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try run jconsole with jar that contains my classes like: cd C:\Program Files\Java\jdk1.6.0_26\bin
I try to run one program in myeclipse where after creating one web project
I am getting the following exception message when I try to run my newly
When I try run make from cmd-console on Windows, it runs Turbo Delphi's make.exe
When I try to run rake test on my newly generated rails application I
I try to run a example code from a book and it gives errors
I'm getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time)
I try to run a medium sized programm with a lot of external jars
I try to run the following raw query in android, it seems not work
I try to run jsf application in myeclipse using jboss web server and following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.