# How to read tmx file in javafx!

**URL:** <https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060>\
**Category:** Questions\
**Created:** [April 13, 2021, 9:32pm UTC](https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060 "2021-04-13T21:32:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joha\_Tam](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/joha_tam/32/3251_2.png) [@Joha\_Tam](https://discourse.mapeditor.org/u/Joha_Tam)\
**Post date:** [April 13, 2021, 9:32pm UTC](https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060/1 "2021-04-13T21:32:45Z")

</div>

Hello!

I read mostly every thread, but couldnt find any useful information. I created a map using tilemap and got a .tmx file. Now i want to load into my Javafx project.

But keep getting errors like Can’t read input file! or No such Directory/File.  
I did exactly the same like him :

> [@Loading tmx map and displaying with JavaFX](https://discourse.mapeditor.org/t/loading-tmx-map-and-displaying-with-javafx/1189):
>
> JavaFX is a very capable and very easy to install graphics library - its even fast enough to do quite advanced 3D (alas no shaders yet!) While there is a java tmx loader I couldn’t find a tutorial that suited me and there is a small wrinkle in that the tmx loader hands you awt images which aren’t suitable for JavaFX The code has some comments and should be reasonably self explanatory, it does make assumptions about tile sizes which it really shouldn’t but with this code and a start you should …

also read this:

> [@\[Java\] Is it possible to load tmx/tsx files from within the jar itself?(libtiled.jar)](https://discourse.mapeditor.org/t/java-is-it-possible-to-load-tmx-tsx-files-from-within-the-jar-itself-libtiled-jar/3644/2):
>
> Hi, As it is possible to load a classpath resource as an InputStream (ClassLoader.getResourceAsStream(String)), you should be able to use the TMXMapReader.readMap(InputStream) and TMXMapReader.readTileset(InputStream) methods.

But he didnt offer the solution. Can someone help me pls?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [April 14, 2021, 8:37am UTC](https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060/2 "2021-04-14T08:37:21Z")

</div>

@Joha_Tam Welcome to the Tiled forum!

If this is not about JavaFX but rather about loading the files from a JAR then my answer in the latter thread may help:

> [@\[Java\] Is it possible to load tmx/tsx files from within the jar itself?(libtiled.jar)](https://discourse.mapeditor.org/t/java-is-it-possible-to-load-tmx-tsx-files-from-within-the-jar-itself-libtiled-jar/3644/8):
>
> @Joha_Tam I think this problem was resolved with the following change: Please check whether your version of libtiled-java has this change. The above change even added a test case where the map gets loaded from the JAR.

---

<div class="post-metadata">

**Author:** ![Joha\_Tam](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/joha_tam/32/3251_2.png) [@Joha\_Tam](https://discourse.mapeditor.org/u/Joha_Tam)\
**Post date:** [May 12, 2021, 6:41pm UTC](https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060/3 "2021-05-12T18:41:46Z")

</div>

Hi! I dont have this version on my project, how do I add it to maven ?  
My current maven Pom.xml one looks like this:  
\<dependency  
\<groupId org.mapeditor\</groupId  
\<artifactId libtiled\</artifactId  
\<version 1.2.3 \</version  
\</dependency

And if I clicked to libtiled:  
I get your name on it:  
\<scm  
\<url [https://github.com/bjorn/tiled](https://github.com/bjorn/tiled)\</url  
\<connection scm:git:git://github.com/bjorn/tiled.git \</connection  
\<developerConnection [scm:git:git@github.com](mailto:scm:git:git@github.com):bjorn/tiled.git\</developerConnection  
\</scm

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [May 17, 2021, 7:12am UTC](https://discourse.mapeditor.org/t/how-to-read-tmx-file-in-javafx/5060/4 "2021-05-17T07:12:11Z")

</div>

> [@Joha\_Tam](#):
>
> Hi! I dont have this version on my project, how do I add it to maven ?

Ah, 1.2.3 is the last version published to Maven. In the following issue, there is a snippet showing how you could depend on a “1.4.2-SNAPSHOT” version:

> <https://github.com/mapeditor/tiled/pull/2931>
>
> Upgraded the dependency versions and pushed to sonatype snapshots
> 
> You are abl…e to get a snapshot of release 1.4.2-SNAPSHOT by adding the following to your maven pom:
> \`\`\`
> \<dependencies\>
> \<dependency\>
> \<groupId\>org.mapeditor\</groupId\>
> \<artifactId\>libtiled\</artifactId\>
> \<version\>1.4.2-SNAPSHOT\</version\>
> \<type\>jar\</type\>
> \</dependency\>
> \</dependencies\>
> \<repositories\>
> \<repository\>
> \<id\>sonatype-oss\</id\>
> \<url\>https://oss.sonatype.org/content/repositories/snapshots/\</url\>
> \<snapshots\>
> \<enabled\>true\</enabled\>
> \</snapshots\>
> \</repository\>
> \</repositories\>
> \`\`\`
> \[You can inspect the contents of the archives from here\](https://oss.sonatype.org/#nexus-search;gav~org.mapeditor ~~1.4.2-SNAPSHOT~~ ) 
> Please let me know if you are happy with the release and I will kick off the deploy to maven central

I think the 1.4.2 release will be pushed to Maven Central soon now, but in the meantime you may want to try using the snapshot instead.
