I have two class files: Generator.class(Main)
and Approach.class(Helper)
, which are created when I compile Generator.java code. The code is dependent on two external jars - argparse4j-0.7.0.jar
and org.apache.commons.io.jar
.
In normal scenario, if I need to execute the code, I would have to run below :
java -cp .:argparse4j-0.7.0.jar:org.apache.commons.io.jar Generator
I want to create a jar file so that it is easy to share a single file.
One approach that I found was, to include below in the jar file (Main.jar) - 1. Generator.class 2. Approach.class 3. manifest.txt
Manifest file : manifest.txt
Main-Class: Generator
Class-Path: argparse4j-0.7.0.jar org.apache.commons.io.jar
In this case, I need to share below 3 with the user -
1. Main.jar
2. org.apache.commons.io.jar
3. argparse4j-0.7.0.jar
To run the jar :- java -jar Main.jar
Is it possible to create a single jar file (Main.jar) with below files - 1. Generator.class 2. Approach.class 3. org.apache.commons.io.jar 4. argparse4j-0.7.0.jar 5. manifest.txt
Then only Main.jar needs to be shared with the user and it can be run using : java -jar Main.jar
I gave this a try with the same manifest file as mentioned above but the java command fails to run the jar.