-1

I got a MBTiles Server written in Java here.

https://github.com/jtreml/mbtiles4j

I am new to java. Can anybody briefly discuss how it works. I want to create an eclipse project with this. Specially I am unable to understand the build and deployment part of Readme file. Again, I am just in a learner stage. If the eclipse project run on local server it would be enough for me.

Thanks

1
+50

You can use Eclipse if you want but it isn't necessary.

Type "mvn package" means open console and in folder where you downloaded mbtiles4j. (Folder where pom.xml file resides) type mvn package. mvn is Apache Maven which is build program. Before that you have to change the properties and write where mbtiles file resides as described in mbtiles4j readme. Maven will create WAR file in subdirectory named target.

If you want to use eclipse you seem to need Eclipse IDE for Java EE Developers or if you already have eclipse you need to install plugin Eclipse Java EE Developer Tools and m2eclipse which is Maven plugin for eclipse. (For building mbtiles4j) there also exist plugin for Tomcat.

WAR is file format for Java web applications (Java server pages, static pages etc..). To run it you need Java application server. There are many Java application servers. I would suggest Apache Tomcat 7. Java users should tell you more about that.

To use Tomcat locally it is usually enough to install it and start it. On Linux you can start it with systemctl start tomcat7. By default it runs on port 8080. You should see something on localhost:8080. After that you have to put WAR file in a tomcat webapps folder in Linux this is /usr/share/tomcat7/webapps I don't know where it is in other OS-es. Tomcat will unpack it and it should work.

You only need html to see tiles (Change tileLayer URL and setView coordinates):

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Leaflet Demo</title>
  <meta name="description" content="Demo of leaflet">
  <meta name="author" content="Marko Burjek">
  <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
  <style>
      #map { height: 700px; }
  </style>

</head>

<body>
 <div id="map"></div>
 <script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
  <script>
    var map = L.map('map').setView([46.562483, 15.643975], 13);
    L.tileLayer('http://localhost:8080/mbtiles4j/maribor/{z}/{x}/{y}.png', {
      tms: true
    }).addTo(map);
  </script>

</body>
</html>

Now open this file in a browser and you should see tiles. I hope this will help you. I would add more links but I don't have enough reputation.

  • In cmd prompt "BUILD FAILED". I have installed latest maven 3.2.1. I think you are giving the right answer. I am ending the Bounty with giving you 50 Reputation so that you can add more links. – Devils Dream Mar 20 '14 at 7:24
  • Can you copy everything that mvn package outputs on pastbin.com . Which OS do you have?. – MaBu Mar 20 '14 at 7:51
  • I am not used to with pastbin.com. How can I copy there? – Devils Dream Mar 20 '14 at 9:03
  • Its probably pastebin.com. I have pasted the error message with following title "mvn package error message" pastebin.com/xSYrQB2v – Devils Dream Mar 20 '14 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.