How to run a class of jar files

Asked 2 years ago, Updated 2 years ago, 75 views

There is a jar file called myJar.jar in myfolder. I want to call myClass in this jar file, so can I know which command to enter?

I did java-cp myJar.jar.myClass, but I can't.

command-line-argument java jar

2022-09-22 22:10

1 Answers

java -cp myjar.jar com.mypackage.myClass Do it like this. Unless the class is in the package java -cp myjar.jar myClass You can say that.

The location to execute the command is myJar.Unless it's in the same directory as jar On Linux, java -cp /myfolder/myjar.jar com.mypackage.myClass In Windows, java -cp c:\myfolder\myjar.jar com.mypackage.myClass You can say that.


2022-09-22 22:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.