I have a problem with building an executable jar using maven it create a jar but I can't open it because it doesn't find my file, and I don't know what to do anymore I am using this for loading a file, if I add an absolute path to file it works great
ClassLoader classLoader = SelectionLab.class.getClassLoader();
File file = new File(classLoader.getResource("Opstine.shp").getFile());
if (file == null) {
return;
}
and here is part of my pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>geotools.SelectionLab</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I tried to get absolute path as messagepane and after exporting shapefile I get this
but I am not sure is it searching for file in jar on path F:\workspace\osma_grupa\osma_grupa\target\osma_grupa-0.0.1-SNAPSHOT-jar-with-dependencies.jar
or it use also this part before file:. I just checked and there is file in root of jar