I have created a maven project which needs tools.jar to be included. I have added the jar into the lib folder and included the following in the pom.xml.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<scope>system</scope>
<version>1.8.0</version>
<systemPath>${project.basedir}\src\lib\tools.jar</systemPath>
</dependency>
When have also added the following plugin to create executable jar for the project.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>umlparser.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
I have built the jar using "mvn clean package assembly:single" This has created an executable jar file with name myproject-jar-with-dependencies.
But when I am trying to run the jar file with java -jar it is unable to get the tools.jar. I am getting the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main
at org.umlgraph.doclet.UmlGraph.main(UmlGraph.java:70)
at umlparser.Main.main(Main.java:19)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javadoc.Main
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)
... 2 more
But when I am exporting it as runnable jar from eclipse it is working as expected. What is the issue with the maven package? Am I missing something here?
EDIT
I have tried to import the tools.jar dependency from the java_home instead of project path.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0_241</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
Still I am getting the same issue.
Note: The tools.jar is not used in my program. It is being used by one of the jars that I have included - "UMLGraph.jar".