Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts

Friday, April 5, 2019

Run class in Jar file - How to run a jar file from command line

Run class in Jar file

In this post, We will learn how to run a Jar file from command prompt with main method and without main method. This is very useful in unix environment to run the jobs in nohup mode. But, now we will be focusing running jar file in windows operating system.


Run class in Jar file - How to run a jar file from command line


How to run a jar file from command line

If you have a jar file called myJavaJar.jar located in /myJavafolder and you want to use the class called myJavaClass from it, How do you run this java program from command line?

I thought it would be to go into the directory and say java -cp myJavaJar.jar myJavaClass but that isn't working.