Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How do you properly build a jar with libgdx?  (Read 3193 times)
0 Members and 1 Guest are viewing this topic.
Offline tyeeeee1
« Posted 2013-06-16 22:19:53 »

Hey,

I finally finished making up a little test game while going through the libgdx tutorials and I want to build the jar file so I can show it to one of my friends. I've tried doing this a few different ways at this point but the jar never runs. I've tried exporting as a jar and as an executable jar with various different options selected, I've also tried running it with the required libgdx libraries within the jar, outside of the jar and with the assets folder within and outside of the jar but nothing works.

The game runs properly when running it from eclipse and I've made sure that there are no errors coming from any of the classes before building the jar so I'm not sure what's up.

Edit: BTW, I'm only using libgdx for desktop; I don't care about android, mac or whatever else there was.
Offline ReBirth
« Reply #1 - Posted 2013-06-17 06:39:08 »

Eclipse, project properties, build path, export, check em all.

Have you tried fat jar? It is the easiest way to bundle jar and guaranteed to work.

Offline tyeeeee1
« Reply #2 - Posted 2013-06-17 16:37:13 »

Eclipse, project properties, build path, export, check em all.

Have you tried fat jar? It is the easiest way to bundle jar and guaranteed to work.

I just tried both fat jar and checking everything but neither of those worked either. The assets folder is also never included in the jar so I've had to keep manually adding it after the jar is created. Prom is today so I probably won't get to reply again tonight; below is a link to download my project folder, maybe I'm just exporting this wrong?

http://www.mediafire.com/download/4quc57ud5pzakkq/Project_01.rar
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RUSD

Junior Member


Projects: 2



« Reply #3 - Posted 2013-06-17 20:01:02 »

I would like to know the solution to this to.  I Don't know how to pack the resources into the jar file and I'm guessing that is the problem.
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #4 - Posted 2013-06-17 21:30:41 »

When I export my libgdx projects (and they work fine when I do) is right click the desktop project -> export -> select runnable jar file click next -> Select proper launch configuration and export destination. Also make sure packag required libraries into generated jar is selected. Then click finish. This seems to work great for me...

Offline ReBirth
« Reply #5 - Posted 2013-06-18 04:46:30 »

Like wreed said, choose Runnable jar export, not the normal one. It will add the manifest greatly. For assets, check project properties if it's included as part of exporting.

Offline RUSD

Junior Member


Projects: 2



« Reply #6 - Posted 2013-06-18 19:00:49 »

I've done that before, but its working this time.  I don't know what i did differently.
Offline tyeeeee1
« Reply #7 - Posted 2013-06-18 22:57:04 »

When I export my libgdx projects (and they work fine when I do) is right click the desktop project -> export -> select runnable jar file click next -> Select proper launch configuration and export destination. Also make sure packag required libraries into generated jar is selected. Then click finish. This seems to work great for me...

Just tried that, it didn't work. =/
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #8 - Posted 2013-06-19 17:19:09 »

Just tried that, it didn't work. =/

You are storing all assets in the android project assets folder right?

Offline tyeeeee1
« Reply #9 - Posted 2013-06-20 00:40:13 »

Just tried that, it didn't work. =/

You are storing all assets in the android project assets folder right?

No; they're all in the assets folder under the project folder. I followed this ( http://www.java-gaming.org/topics/libgdx-how-do-i-load-local-assets-without-an-android-project/29148/msg/266799/view.html#msg266799 ) guide so that I wouldn't need to deal with all that android, linux and mac stuff. I'm only testing on desktop so the rest didn't matter.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #10 - Posted 2013-06-20 04:51:03 »

It matters in this situation Wink Sometimes the default way makes things easy

Offline tyeeeee1
« Reply #11 - Posted 2013-06-20 18:00:54 »

It matters in this situation Wink Sometimes the default way makes things easy

Then how do I fix all this junk? It shouldn't need a bunch of useless project folders just to compile and run for desktop.
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #12 - Posted 2013-06-20 21:42:59 »

Hey, im not saying this is the best solution im just saying its a solution

Offline tyeeeee1
« Reply #13 - Posted 2013-06-21 20:52:49 »

I just went in to poke around at my code a bit after not looking at it for a few days. It ends up that the crashing was caused by Eclipse not putting the assets folder into the jar but rather putting the assets in directly; the code required them to be within an "assets" folder. After that the program started opening and crashing right away so I poked around a bit more and found that it was crashing because the "Save.txt" file wasn't being created for it to save data into.

Everything works now!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (57 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!