I am having a multi-module project structure, when I am building a jar from a module, its getting build but when I try to run that jar using:
java -jar <path to that jar>.jar
It gives this eror:
Could not find or load main class <packageName.ClassNameWhereMyMainMethodIS>.java
How can I resolve this?
You need to create a runnable jar or use
java -cp <path to that jar>.jar full.package.name.ClassName
when you don't define a manifest which indicate which class within the JAR file is your application's entry point.
You can run using:
java -cp TestApp.jar com.test.HelloWorld
-cp adds that jar to your classpath
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.