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

  • SEARCH
  • Home
  • 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 8394975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:11:11+00:00 2026-06-09T20:11:11+00:00

I am having a problem that when I create a runnable jar file that

  • 0

I am having a problem that when I create a runnable jar file that nothing is loading on the screen. After some research, I believe the problem is to do with how I am loading the images but I am not sure of the solution to fix that.

The code below is just a snippet of how I load the images.

Thank you~

public class Screen extends JPanel implements Runnable {
public Thread thread = new Thread(this); 

public static Image[] tileset_ground = new Image[100]; 
public static Image[] tileset_air = new Image[100]; 
public static Image[] tileset_res = new Image[100];
public static Image[] tileset_mob = new Image[100]; 
public static Image[] tileset_characters = new Image[10];

public static int myWidth, myHeight; 
public static int coinage, health;
public static int randomMob = 0;
public static int level = 1, maxLevel = 5;
public static int killed = 0;
public static int killsToWin = 0; 
public static int winTime = 4000, winFrame = 0;
public int mobsCreated = 0; 

public static boolean isFirst = true;
public static boolean isDebug = false;
public static boolean isWin = false;
public static boolean isMainMenu = true;
public static boolean exit = false;

public static boolean clicked = false;

public static Point mse = new Point(0,0); 

public static Room room; 
public static Save save;
public static Store store; 
public static MainMenu mainMenu;

public static Mob[] mobs = new Mob[100]; 


public Screen(Frame frame) {
    frame.addMouseListener(new KeyHandle());
    frame.addMouseMotionListener(new KeyHandle());
    thread.start(); 
}

public void hasWon(){
    if(killsToWin == killed){
        isWin = true;
        killed = 0;
        coinage = 10;
    }
}

public void define() {
    room = new Room(); 
    save = new Save(); 
    store = new Store(); 
    coinage = Values.coinage;
    health = Values.health;


    for(int i =0; i<tileset_ground.length; i++) {
        tileset_ground[i] = new ImageIcon("res/tileset_ground.png").getImage(); 
        tileset_ground[i] = createImage(new FilteredImageSource(tileset_ground[i].getSource(), new CropImageFilter(0,26*i,26,26)));
    }

    for(int i =0; i<tileset_air.length; i++) {
        tileset_air[i] = new ImageIcon("res/tileset_air.png").getImage(); 
        tileset_air[i] = createImage(new FilteredImageSource(tileset_air[i].getSource(), new CropImageFilter(0,26*i,26,26)));
    }

    tileset_res[0] = new ImageIcon("res/cell.png").getImage();
    tileset_res[1] = new ImageIcon("res/coin.png").getImage();
    tileset_res[2] = new ImageIcon("res/heart.png").getImage(); 
    tileset_res[3] = new ImageIcon("res/startbutton.png").getImage();
    tileset_res[4] = new ImageIcon("res/quitbutton.png").getImage();
    tileset_res[5] = new ImageIcon("res/cellchar.png").getImage();
    tileset_res[6] = new ImageIcon("res/mainmenu.png").getImage();


    tileset_mob[0] = new ImageIcon("res/pixelcody.png").getImage(); 
    tileset_mob[1] = new ImageIcon("res/floatingmob1.png").getImage();
    tileset_mob[10] = new ImageIcon("res/pixelraghev.png").getImage();

    tileset_characters[1] = new ImageIcon("res/pixelcody.png").getImage();
    tileset_characters[2] = new ImageIcon("res/pixelraghev.png").getImage();
    tileset_characters[4] = new ImageIcon("res/pixelbio.png").getImage();
    tileset_characters[3] = new ImageIcon("res/pixelpeter.png").getImage();
    tileset_characters[5] = new ImageIcon("res/pixelkat.png").getImage();
    tileset_characters[7] = new ImageIcon("res/pixelvicky.png").getImage();
    tileset_characters[6] = new ImageIcon("res/pixelkyle.png").getImage();
  • 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-09T20:11:12+00:00Added an answer on June 9, 2026 at 8:11 pm

    This is probably due to an exception being thrown on startup.

    In order to load from a .jar, you must modify your code slightly. For your ImageIcon constructors, you need to change them.

    ImageIcon whatever = new ImageIcon(ImageIO.read(getClass().getResource("path to image")));
    

    Be sure to import ImageIO:
    import javax.imageio.ImageIO;

    However, due to the fact that you are using arrays of Images, I would recommend simply using ImageIO.read() without messing with using ImageIcons. Also, in my experience, I have always had to preface the path to the image with an additional “/”.

    This should work.

    One way I try to see if something is going wrong is put a try…catch around the entire program and catch Exception. I then print the stack trace to a file.

    try {
    ...
    }catch(Exception e){
    PrintWriter writer = new PrintWriter("trace.txt");
    e.printStackTrace(writer);
    writer.close();}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem trying to create a Javascript function that checks all the
I'm trying to create this effect: http://www.thecssninja.com/demo/css_tree/ the problem I'm having is that the
I'm having some problems with some commands in Java. I created a JAR that
I am having a problem producing a working jar file. I would like to
I'm trying to create a tooltip with jquery. However I'm having a problem that
I am having that problem that I got some items on a list that
I am trying to create a login form. The problem that I am having
All, The problem I am having is that I created a ListView and set
The problem i'm having is that i've created a web service, and a windows
I am having problem that when i am trying to submit the form by

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.