[LibGdx] - Exported to Jar, and Gamescreen wont show, but other Screens will?

All right, so i have exported a game i have created to an runnable jar file as i have many times before. Earlier i haven’t had a problem like this, the last time i exported it was on friday, and now when the last version is finished and i export it, the window just closes when i have gone trough a few screens, flash, credits and menu, no error is given if i run it trough commandline. The game works fine if i run it trough eclipse. I have checked the buildpath and the asset folder is there and all. I have opened the jar with winrar and checked to see that all images are there, and they are. I have tried both to extract and package the libraries. I am at a total loss…

I looked around and only could find one thread on this, and that was an error with a static filepath.

I really need this fixed since it’s supposed to be turned in on tuesday. :confused:

Do me a favor, post the main code here.

After that, wrap it inside a try { }catch(Exception ex) { JOptionPane.showMessageDialog(null,"" + ex.getMessage);

To do something easier then @Andre’s example you could just run it from console and see the error that way without modifying any code.

I have run it trough the console on windows, but i get no error showing up. I have tried added the try and catch on several different positions in the code, invoking the switch to GameScreen, and on the constructor in GameScreen. I also tried adding a few System.out.printlns here and there and none of them showed up.

Take a screenshot of your .jar with the libraries folder location and the eclipse export settings.

Here is a screenshot proving that the libgdx stuff and others are in there, the folder is filled with classlibraries and so on.

And here is a screenshot of the settings.

I have tried both extracting and packaging the libraries, nothing works. If it would have been a libraries problem, the first screens wouldnt work either, since they use tween stuff and the libraries associated with that. The only things i have added since friday are more images, which i have checked, they are there in the jar. Some code, and a new death/highscore screen. The code are simple loops to print the images up.

edit I tried to comment out everything but the camera and map generation from the gamescreen and it still doesnt run.

try something for me, might be a long shot but …

(x) copy required … sub-folder bla bla bla.

copy main code here as well.

What main code are you after? just main class?


package com.sabo.zombies;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
	public static void main(String[] args) {
		
	
		LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
		cfg.title = "Zombies";
		cfg.useGL20 = true;
		cfg.width = 480;
		cfg.height = 320;
	    cfg.resizable = false;
		
		new LwjglApplication(new Zombies(), cfg);
	
}
}


the window just closes when i have gone trough a few screens

Test :
Comment everything in dispose method or that calls dispose();

Are you using assetManager or Atlas ?

There is nothing in the GameScreen dispose, the only one that got is the MainMenu screen, which also uses an atlas. But nothing else does(neither do they use and atlas), havent gotten into learning that or the assetmanager yet. Anyways, i have skipped all the screens in front of gamescreen and go directly to the gamescreen when the game launches, and the game crashes. So i dont think that has anything to do with it.

It crashes how? What you have in show() method or hide()

I don’t know how it crashes, it doesn’t give me any error.

Show:


		map = new TmxMapLoader().load("maps/untitled.tmx");
		mapRender = new OrthogonalTiledMapRenderer(map);
		camera = new OrthographicCamera(width, height);
		player = new Player(new Vector2(width / 2, height /2), 60, (TiledMapTileLayer) map.getLayers().get(0), 4, bullets, camera);
		bullets = new ArrayList<Bullet>();
		enemies = new ArrayList<Monster>();
		Gdx.input.setInputProcessor(player);

There is nothing new in there, i don’t remember the last time i edited anything in show().

Hide has nothing, i even commented out the call to the empty dispose. Resize is just changing the viewport and such, but isnt called since the window isnt resizable anymore.(i tried making it resizable again, but it crashes anyway.)

Can you try running it on a different computer?

I have tried on my laptop, no luck.
Works in eclipse, but not exported jar. :confused:

The only conceivable reason why it doesn’t work is because your resources are messing up. I’ve barely used LibGDX though. Are LibGDX games just export and run? Or do you have to run them through JarSplicer first?

I am working my way slowly trough the game uncommenting stuff as i extract the game from a working state to a crashing state. I think its somewhere in the entity / player class. But since i dont get an error i have no idea.

Yea, just export and run. The assets are there in the .jar file, so i am baffled.

Ok… i am a little pissed now.

Turns out Eclipse is not case sensitive when it comes to file names, whilst the java run outside Eclipse is…

Why would you ever not type the name exactly the same anyway? That’s just silly and isn’t the JVM’s fault nor is it Eclipse’s either.

I always type the names the same way, but for some reason this time it was different.

And how is it not eclipses fault if it doesn’t pay attention to such an obvious error?

Compilers only do what you tell it to do. If you get in the habit of not typing everything exactly correct, then how can you expect the program to know what to do? Eclipse is actually creating bad habits, yes, but only if you let yourself slip into them.