Jimmt
Jimmt

Reputation: 902

LibGDX packing .tmx maps

I am attempting to pack my .tmx map through the command line, but I keep getting this:

Could not find or load main class libs.gdx-audio-sources.jar

I have a feeling this is just a random .jar, anyways it is inside a libs folder inside my assets folder. The command I type in is:

java -cp libs/* tiles output file   (sorry this shouldn't be a comment)

libs folder contains all the jars, I literally added every single libGDX jar just to be sure. tiles is the folder with my .tmx, image pack file, and image, and output is my empty output folder. If I just input the directories of /tiles and /output as arguments to TiledMapPacker.main (in an array of course) I just get

Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/tools/imagepacker/TexturePacker$Settings
at com.badlogic.gdx.tiledmappacker.TiledMapPacker.main(TiledMapPacker.java:351)
at com.game.packer.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.tools.imagepacker.TexturePacker$Settings
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

I'm pretty sure imagepacker.texturepacker$settings is inside tiled-preprocessor.jar, which IS inside my libs folder, so I don't know whats going on.

Upvotes: 3

Views: 776

Answers (2)

Ben Poulson
Ben Poulson

Reputation: 3505

Luckily you won't need to do this anymore.
They have completely refactored the Tiled map code.

Upvotes: 1

Thomas
Thomas

Reputation: 181745

The trouble is with shell expansion:

java -cp libs/* tiles output file

The shell will expand libs/* to all files in the directory, so you get this command line:

java -cp libs/gdx-audio.jar libs/gdx-audio-sources.jar ... tiles output file

And -cp expects a colon-separated list, not space-separated. So the second JAR file is interpreted as the "main class" argument, though libs/gdx-audio-sources.jar is obviously not the name of a class.

So we need colon-separated filenames which can be done like this:

java -cp $(printf "%s:" libs/*) tiles output file

Upvotes: 0

Related Questions