mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

I'm being stupid but please help, it will only take < 1 min. #3284

independence106 posted onGitHub

  • Launch the TMX Viewer using java -jar tmxviewer-<Version>.jar [file], uhh where do I find out which version it is?

If you managed to build the package (by running mvn package, as documented in the README.md), you should be able to find the following .jar files:

bjorn@magni:~/tiled/util/java$ find -name \*.jar 
./libtiled-java/target/libtiled-1.4.2-SNAPSHOT.jar
./libtiled-java/target/generated-test-resources/resources.jar
./libtiled-java/target/test-classes/resources.jar
./tmxviewer-java/target/tmxviewer-1.4.2-SNAPSHOT.jar
./tmxviewer-java/target/original-tmxviewer-1.4.2-SNAPSHOT.jar

So the version is currently "1.4.2-SNAPSHOT". You can run this tmxviewer as follows:

bjorn@magni:~/tiled/util/java$ java -jar ./tmxviewer-java/target/tmxviewer-1.4.2-SNAPSHOT.jar
Java TMX Viewer

When a parameter is given, it can either be a file name or an 
option starting with '-'. These options are available:

-?
-help
    Displays this help message

However, personally I was unable to actually use it to load a map:

bjorn@magni:~/tiled/util/java$ java -jar ./tmxviewer-java/target/tmxviewer-1.4.2-SNAPSHOT.jar ../../examples/desert.tmx 
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:62)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:434)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:282)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:109)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1142)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:141)
    at com.sun.xml.bind.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:35)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:404)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
    at org.mapeditor.io.TMXMapReader.<init>(TMXMapReader.java:106)
    at TMXViewer.main(TMXViewer.java:81)
Caused by: java.lang.IllegalStateException: Can't find ReflectionNavigator class
    at com.sun.xml.bind.v2.model.impl.Utils.<clinit>(Utils.java:63)
    ... 12 more

I'm not using Java anymore, so I'm not sure what could be the problem here.

@theNestruo, do you have an idea? Did I install the wrong Java on Ubuntu? I took default-jdk, which provided me with javac 11.0.13.

posted by bjorn about 3 years ago

Seems to be related with JAXB and Java >= 11. I'll take a look at it this evening.

posted by theNestruo about 3 years ago

It's definitely related to that, but I've been unable to solve it.

Generally speaking, JAXB has always been troublesome in Java: lots of slightly different implementations, questionably named dependencies (sun? glassfish?), lots of different Maven plugins... Java 11 made things worse due javax.* to jakarta.* repackaging and JAXB being removed from Java SE. And I haven't found (yet) an updated Maven plugin that supports the extensions currently used in XJB (such as annotations)...

As any solution I can think of implies a lot of changes in the code, let me think about it twice before proposing a proper solution.

posted by theNestruo about 3 years ago

I've personally never been a fan of using reflection in the first place...

posted by bjorn about 3 years ago

@bjorn Yea, that was the issue I was getting before.

posted by independence106 about 3 years ago

Just wondering, since there is an issue with jaxb, are there any other map editors that can be used similar to Tiled? @bjorn @theNestruo

posted by independence106 about 3 years ago

@independence106 Maybe you could switch to something else than libtiled-java for loading the Tiled map? For example, libGDX has built-in support for loading Tiled maps. Alternatively, you could save the map in the JSON format, which may be easier to load.

Also, it seems that while JAXB has been removed in Java 11, there's a quick fix by adding the necessary dependencies to the pom.xml:

I played around a bit, but couldn't get it to work based on the methods above (doesn't mean they can't work of course). Or maybe we need to switch to a different Maven plugin altogether:

posted by bjorn about 3 years ago

I've been playing around with Jackson (XML extension) for parsing the XML, while still using existing JAXB plugin, annotations and generated classes. Ultimately got it working (no runtime technical errors)... but the MapData.layers were always null due Jackson not processing the @XmlElements annotations generated from the <xs:choice> elements :(

posted by theNestruo about 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests