I use external jar jimObjModelImporterJFX.jar
, because it's not hosted on Maven repository and I'm adding it with maven dependency like below
<dependency>
<groupId>jimObjModelImporterJFX</groupId>
<artifactId>jimObjModelImporterJFX</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${path}</systemPath>
</dependency>
I could not add it in IntelliJ by Project Structure
-> Modules
-> Dependencies
-> +
because later on I'd have errors during maven task.
Then I have plugin to add dependencies (but it's not adding and I don't know why, but on other topics people say that it should)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>myMainClass</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
After that I run maven task clean compile assembly:single
and when it's done I have a jar
in target
folder.
When I run it from cmd I have an error
Caused by: java.lang.ClassNotFoundException: com.interactivemesh.jfx.importer.ImportException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 22 more
It's because my application jar file doesn't contains this library inside. Structure is like: archive |-groupid.artifactid (.class files here) |-layouts (with .fxml file because it's javaFX app) |-META-INF (with MANIFEST.MF)
How to put this jimObjModelImporterJFX.jar
into my app?
system
dependencies will never end up in the resulting jar by definition. They are supposed to be explicitly provided.
You can add the jar to your local .m2 repository using the maven command line util mvn
like this
mvn install:install-file -Dfile=<path-to-jar-file> \
-DgroupId=<yourGroupId> \
-DartifactId=<yourArtifactId> \
-Dversion=<yourVersion> \
-Dpackaging=jar
and then use the "normal" dependency notation
<dependency>
<groupId>yourGroupId</groupId>
<artifactId>yourArtifactId</artifactId>
<version>yourVersion</version>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.