[SOLVED] LibGDX/Eclipse Exporting Runnable Jar

Hi. I’m in Ludum Dare 31 and I need an answer fast. I’m trying to export my LibGDX project in Eclipse as a Runnable Jar. When I run the jar, the window opens for a few seconds, and then closes.
I’m guessing that’s because it can’t load one of my assets, but the project runs fine in Eclipse. I’ve also exported projects like this the same way before and never ran into this problem. I am exporting the desktop project, clicking Runnable JAR file, Package required libraries into generated jar, and the launch configuration goes to the DesktopLauncher class of my desktop project.

So again, when I run the runnable jar by double clicking on it, the window opens for a few seconds, then closes. I’m loading all my assets at the beginning of the program, so it’s probably something to do with that. Again, it’s fine just running it in Ecliipse. Should I run it in the command prompt? How exactly would I do that?

Try running it through command prompt, and seeing what error pops up. To do this, open up cmd (windows key-r, cmd), navigate to the directory of your jar using cd

cd C:\Users\Jimmt\Downloads

(for example) and then do

java -jar nameofjar.jar

Right. Did that, got the error message. Thanks for showing me how to run a jar like that btw.
So it’s a GdxRuntimeException caused by File not found: fonts/winter.TTF

So it can’t load my font. But why does the project in Eclipse run just fine?

I load the font like this:


FileHandleResolver resolver = new InternalFileHandleResolver();
loader.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
loader.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
FreeTypeFontLoaderParameter param = new FreeTypeFontLoaderParameter();
param.fontParameters.size = 75;
param.fontFileName = "fonts/winter.ttf";
loader.load("fonts/winter.ttf", BitmapFont.class, param);

loader is an instance of AssetManager. I tried changing all of the “.ttf” extensions to “.TTF”, but then I just get an ExceptionInInitializerError when I run it in Eclipse.

So what now?

With AssetManager, I’ve only gotten it to work by putting a folder with all the assets in the same directory as the .jar. This probably isn’t the correct method, but it does work.

Thanks so so so much for the quick and useful responses. I finally got it working.
This line:


param.fontFileName = "fonts/winter.ttf";

Should be:


param.fontFileName = "fonts/winter.TTF";

Seriously!??!!? I have no idea why that exception was only after I exported it, but hey, it’s working.
Thank you so much Jimmt. I love this community :smiley: