Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an executable out of my LIBGDX game

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. 
like image 949
Brian Diehr Avatar asked Jan 27 '12 04:01

Brian Diehr


4 Answers

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

like image 170
Nacef Avatar answered Nov 11 '22 02:11

Nacef


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

like image 24
Kyrremann Avatar answered Nov 11 '22 04:11

Kyrremann


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.)

like image 5
P.T. Avatar answered Nov 11 '22 04:11

P.T.


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

like image 1
Thad.Nutting Avatar answered Nov 11 '22 03:11

Thad.Nutting