我一直在寻找使用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