简体   繁体   中英

Run jar file from unix command prompt (ERROR)

I have a java project that has 10 .java files. A1.java, A2.java......A9.java and Main.java. The project contains a package grand.big.medium.small and all the .java files are inside this package.

I have compiled and created an executable jar file for the project using:

javac grand/big/medium/small/*.java

to run the project I used the command

java -cp . grand/big/medium/small/Main

to create the jar I used the command

jar -cvmf manifest.txt MyJAR.jar *.class

I want to run the jar file from command prompt and I am using the commad

java -cp . -jar grand/big/medium/small/MyJAR.jar

and I getting an error: Error: Could not find or load main class Main

please can anyone tell me why I am getting this error?

Run as:

java -cp . -jar grand/big/medium/small/MyJAR.jar grand.big.medium.small.Main

Assuming you have grand as a directory within current directory and directory hierarchy follows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM