Reputation: 365
I have 2 main classes in the project and i want to merge them into a single jar. because i want to use this jar in another project. so can you please suggest a solution for this.
Upvotes: 0
Views: 34
Reputation: 520878
You would go about this the same you would creating a JAR file from 2 classes which both do not have a main
method:
jar -cvf your_jar.jar MainClass1.java MainClass2.java
If you want to choose one of the main
methods to be the one which will execute by default when the JAR is run, then you can create a manifest file with the following contents:
Main-Class: MainClass1 (Manifest.txt)
Then you can run the jar
tool like this:
jar -cvfm jarfile.jar Manifest.txt MainClass1.java MainClass2.java
Upvotes: 1