Note: it's clear from this question that you understand the reasoning behind using data files, but I will leave my preamble here for the benefit of others who come across this question in the future
Now is my first problem how to create the map in java. I designed a small map with tiled but not sure how to use it now:
I can't comment yet but you seem to be asking:
How can I export this map from tiled so I can actually use it in my game?
Why Data Files?
To answer this I should make a few things clear:
- Since every game needs different information about what the world looks like, the types and statuses of the objects in your game, etc... there is no ideal way for that data to be stored that will be perfect for every single game.
- At the same time it is of great importance that map editors like tiled make it as easy as possible for people to use the map data in their game. See this question. It would be great if there were some standardized way that maps from these editors could be stored so that they could be read easily by machines and (optionally) by humans. Enter data file formats like json and TMX (there are many others). Data files that follow these and other specifications store data in a structure that can be easily parsed by computer programs (such as your game). Tiled exports TMX files.
- Q. Oh fiddlesticks, are you telling me I have to write and debug a bunch of code to read these convoluted text files in order to get the map into my game?
A. Not necessarily. To this end there are many helper libraries available that will do much of this work for you. see this page.
According to the Tiled wiki Support for TMX page:
A library for loading TMX files is included with Tiled at
You shouldn't even have to download anything :) You will still have to figure out how to use the loader yourself; playing with the tests would be a good start.
I hope this helps!