There are several classes in the JAR file ( Test.jar ) with the main method ( Class1 , Class2 ).
How to run a given class from the console?
java -jar Test.jar Class1 java -jar Test.jar Class2 There are several classes in the JAR file ( Test.jar ) with the main method ( Class1 , Class2 ).
How to run a given class from the console?
java -jar Test.jar Class1 java -jar Test.jar Class2 At startup, you can specify any executable class. In order to have a class available from a given JAR, you need to add it to the classpath:
java -cp Test.jar Class1 If the parameter Main-Class is registered in the JAR manifest
Manifest-Version: 1.0 Main-Class: Class1 , then the specified class will be launched when the executable JAR is started:
java -jar Test.jar References:
Source: https://ru.stackoverflow.com/questions/628454/
All Articles