Question

I've never made a program into an executable before, and I've been looking into how to do this for some time now. When I try to put it into a jar everything works fine but when I try to run it nothing happens.

How do I make my game into an executable so it can be run (on windows, not android) I feel like I am not Linking it to the libraries or something... Not sure. Thanks!

Edit: I should add I get the error

JAR export finished with warnings. See details for additional information. 
duplicate entry: com/badlogic/gdx/utils/arial-15.fnt 
duplicate entry: com/badlogic/gdx/utils/arial-15.fnt 
duplicate entry: com/badlogic/gdx/utils/arial-15.png 
duplicate entry: com/badlogic/gdx/utils/arial-15.png 
Jar export finished with problems. 
See details for additional information. 
Was it helpful?

Solution

Your problem is that when you use eclipse export as Executable jar file it does not include the assets (graphical, sounds ...) that you used in your gdx project. What you can do manually is either copy your assets folder right next to the generated jar file or include your assets folder in your jar file with your favorite zip management tool.

Another way would be to use this same eclipse export wizard and check "Save as ANT script" and then edit the generated ant file to include all the files and folders needed by your app.

Hope this helps

OTHER TIPS

This is an old question, but if you are using a new version of LibGDX and Gradle you can use the command line to make an executable.

There are several commands, but these are for packaging:

Desktop

gradlew desktop:dist

Android (unsigned)

gradlew android:assembleRelease

iOS

gradlew ios:createIPA

Web

gradlew html:dist

Read more at https://github.com/libgdx/libgdx/wiki/Gradle-on-the-Commandline

I'm assuming your application is setup as the libgdx wiki page suggests (with a "main project" and separate "desktop" and "android" projects that share the sources from the "main" project).

Since your app is written in Java, it requires a JVM to run on a desktop. You have to decide if you want to package that up, or rely on a JVM already being installed by the user. I believe packaging up the JVM with Java class files is very complicated and raises a host of other issues (and it becomes very platform specific). So, I believe most libgdx-based games get distributed as an executable Jar file, which means the user must already have Java. (It works for Minecraft, so its probably good enough for you, too. :)

Eclipse makes that really easy: File -> Export ... -> Java -> Executable Jar File. There may be additional steps required to include assets like your app's images and sounds into this .jar file. (My game is currently "asset free", so I don't have any experience with this part.)

You might also consider side-stepping the desktop executable, and packaging your game as an applet and running it in a web browser so there is very little "installation" required by the folks you want to show it to. Here's a walkthrough for making an applet from a libgdx-based game. (I haven't actually tried this myself yet, but I do have a libgdx-based game that I'm planning on doing this for.)

If you're using Android Studio, you can create a custom configuration to distribute from within the program.

On the Run dropdown list select edit configurations.

Click the "+". Select Gradle.

On the right half of that screen give your configuration a Name.

Gradle Project: Use the browse button to select your desktop application. This will look something like (project name):desktop

Tasks: type "desktop:dist"

Apply.

Close the configuration editor and select your new configuration from the dropdown. Hit run and it should build your project.

Your new Jar file should be located in (ProjectName)/desktop/build/libs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top