Running a Java class from Jar through the command line

I have a jar file with several classes that have static core methods. Can I execute them inside the jar from the command line? If not, can I execute them one by one?

+3
source share
2 answers

Window

java -classpath .;path/to/yourlib.jar your.package.path.ClassWithMain

Linux (I think)

java -classpath .:path/to/yourlib.jar your.package.path.ClassWithMain

Or if you are not using only packages (for Windows)

java -classpath .;path/to/yourlib.jar ClassWithMain
+12
source

If you don’t know which class has a static main method, you can use some java IDE, for example IntelliJ IDEA, it can find classes using the main () method, and then you can run it in your project.

0
source

Source: https://habr.com/ru/post/1723523/


All Articles