I create jar file in IDEA Build>Build Artifacts. But can\'t run it with java -jar jarname.jar
- Error: Could not find or load main class Hello
. MAN
i believe your manifest file must say what the main class is if you want it to auto execute.
Main-Class: Hello
otherwise you need to specify it on the command line when attempting to execute the jar. As far as how to do that with IntelliJ, I can't help you there.
java -cp hello.jar Hello
Note that the reference to the class with the main method is the fully qualified location (package.classname) but since your class has the default package, its not necessary.