I think you can try it like this:
Here is a simple example for you. First, we assume that we have a project directory, for example, D:\javademo . In this working directory, we create the main class HelloWorld.java , and thtat contains our other JAR files, for example commons-lang.jar . Now we have to archive our main classes HelloWorld and commons-lang.jar in the test.jar file.
First we need to edit our manifest file so that we can specify our path class and main class for example:
Manifest-Version: 1.0 Created-By: tony example Class-Path: test.jar commons-lang.jar Main-Class: org.tony.java.HelloWorld
We named this file test.mf Now we use the jar command to generate our JAR file as follows:
jar -cvfm test.jar test.mf -C ./ .
Then it will generate a test.jar JAR file. You can use this command to run this main class using the java command:
java -jar test.jar
This is my decision. Hope this gives you something useful ...
source share