Yes, the problem was due to the missing of apache.commons.lang3. Thank you very much.
But how could I know about this dependency before the compilation? Neither in the pom file, nor in the contents of the jar file (gt-swing-31-SNAPSHOT.jar), there was no name regarding apache.commons.lang3. Also "*mvn dependency:tree -Dincludes=org.geotools:gt-swing:**" could not be helpful. Best, Amir On Fri, Feb 23, 2024 at 4:37 PM Ian Turton <[email protected]> wrote: > it looks like you haven't added (at least) the apache.commons.lang3 jar. > This is what maven excels at so you should probably let it do it's magic > rather than trying to muddle along with out it. > > Ian > > On Fri, 23 Feb 2024 at 14:49, Amirhossein Nikfal <[email protected]> > wrote: > >> The short code below can be compiled and run successfully, but *after >> loading the shapefile*, shows error in line: FileDataStore store = >> FileDataStoreFinder.getDataStore(file); >> >> This is the way I compile and run it: >> java -d . Quickstart.java >> java org.geotools.tutorial.quickstart.Quickstart >> >> Code: >> package org.geotools.tutorial.quickstart; >> >> import java.io.File; >> import org.geotools.api.data.FileDataStore; >> import org.geotools.api.data.FileDataStoreFinder; >> import org.geotools.swing.data.JFileDataStoreChooser; >> >> public class Quickstart { >> public static void main(String[] args) throws Exception { >> File file = JFileDataStoreChooser.showOpenFile("shp", null); >> if (file == null) { >> return; >> } >> FileDataStore store = FileDataStoreFinder.getDataStore(file); >> } >> } >> >> The errors: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> *Feb 23, 2024 3:31:29 PM org.geotools.api.data.FileDataStoreFinder >> getDataStoreWARNING: Could not aquire ESRI(tm) Shapefiles >> (*.shp):java.lang.NoClassDefFoundError: >> org/apache/commons/lang3/SystemUtilsjava.lang.NoClassDefFoundError: >> org/apache/commons/lang3/SystemUtils at >> org.geotools.data.shapefile.files.ShpFiles.init(ShpFiles.java:189) >> at org.geotools.data.shapefile.files.ShpFiles.<init>(ShpFiles.java:147) >> at >> org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:260) >> at >> org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:417) >> at >> org.geotools.api.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:78) >> at >> org.geotools.api.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:55) >> at Quickstart.main(Quickstart.java:31)Caused by: >> java.lang.ClassNotFoundException: org.apache.commons.lang3.SystemUtils >> at >> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) >> at >> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) >> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) >> ... 7 more* >> >> However, it can load the shapefile without problem when it's run by maven: >> mvn exec:java -Dexec.mainClass=org.geotools.tutorial.quickstart.Quickstart >> >> >> Any comment would be appreciated. >> _______________________________________________ >> GeoTools-Devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-devel >> > > > -- > Ian Turton >
_______________________________________________ GeoTools-Devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
