package org.geotools.tutorial.quickstart;

import java.io.File;

import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.map.MapContent;
import org.geotools.styling.SLD;
import org.geotools.styling.Style;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;

 * Prompts the user for a shapefile and displays the contents on the screen in a map frame.
 * <p>
 * This is the GeoTools Quickstart application used in documentationa and tutorials. *
public class Quickstart {

     * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
     * contents on the screen in a map frame
    public static void main(String[] args) throws Exception {
        // display a data store file chooser dialog for shapefiles
        File file = JFileDataStoreChooser.showOpenFile("shp", null);
        if (file == null) {

        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();

        // Create a map content and add our shapefile to it
        MapContent map = new MapContent();

        Style style = SLD.createSimpleStyle(featureSource.getSchema());
        Layer layer = new FeatureLayer(featureSource, style);

        // Now display the map

The last line "JMapFrame.showMap(map)"; required: MapContext found: MapContent

Then I changed

MapContent map = new MapContent();


 MapContext map = new MapContext();

Then the application starts but when I select shape file

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/jai/PropertySource

Am I missing any library? I have installed both jai-1_1_3_lib-windows and jai_imageio

Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/jai/PropertySource
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
  • It seems you have a problem in your java project settings, and the JAI (Java Advanced Imaging) classes are not loaded. Which java SDK do you use? Are you sure JAI is part of the SDK you are using? Which IDE do you use?
    – julien
    Nov 7, 2011 at 10:31
  • @julien I am using Netbeans.
    – kinkajou
    Nov 7, 2011 at 17:22

1 Answer 1


Did you follow the relevant quick start instructions at http://docs.geotools.org/stable/tutorials/index.html? Both include a section on how to set up your environment.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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