Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.
   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) {
            return;
        }

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

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

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

        // Now display the map
        JMapFrame.showMap(map);
    } 
}

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

Then I changed

MapContent map = new MapContent();

To

 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)
share|improve this question
    
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 '11 at 10:31
    
@julien I am using Netbeans. –  kinkajou Nov 7 '11 at 17:22
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
yes of course I used Maven Alternative and started with the example code but it's not working and i installed jai and imageio –  kinkajou Nov 7 '11 at 17:25
    
Although the jar are told to be optional it is required for tutorial to work! –  kinkajou Nov 8 '11 at 6:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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