我一直在尋找使用Eclipse http://docs.geotools.org/latest/userguide/tutorial/quickstart/eclipse.html 的Geotools快速入門教程我跟所有的步驟,這一切都很順利,直到我跑的快速入門級Geotools快速入門教程JFileDataStoreChooser.showOpenFile導致錯誤
當我運行快速入門類。我得到這個錯誤
Exception in thread "main" java.lang.NullPointerException
at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:571)
at sun.awt.shell.Win32ShellFolder2.access$400(Win32ShellFolder2.java:72)
at sun.awt.shell.Win32ShellFolder2$2.call(Win32ShellFolder2.java:298)
at sun.awt.shell.Win32ShellFolder2$2.call(Win32ShellFolder2.java:296)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run(Win32ShellFolderManager2.java:502)
at java.lang.Thread.run(Thread.java:722)
而且我發現這個方法引起的問題JFileDataStoreChooser.showOpenFile
我註釋掉所有其他行除了使用上述的方法之一,仍然得到了同樣的錯誤。 (沒有錯誤,如果我評論說,線以及)
package org.geotools.tutorial;
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
/*********This is the line *********/
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);
}
}
另外,在pom.xml中,我試圖版本8.0-M2和8快照。但沒有運氣...
任何人有任何想法? 模塊geotools.swing有什麼問題嗎?
感謝
感謝您的回答。我試圖谷歌關鍵字。在http://netbeans.org/bugzilla/show_bug.cgi?id=186615中,它表示它已在6u21中修復,在http://www.dbvis.com/forum/message.jspa?messageID=10866中,它表示恢復回到版本6u18。我嘗試了兩個,仍然得到NullPointerException但不同的堆棧跟蹤。我的原始版本是JDK 7 – shane716