简体   繁体   中英

Creating runable Jar from IntelliJ, trying to run in cmd gives 'Error: Could not find or load main class com.....'

I'm using IntellIj to try and create a runnable Jar out of my program. I've gotten a runnable jar to execute in cmd correctly for a simple hello world program, but when I try doing the same exact steps for the larger project I get the Error:

Error: Could not find or load main class com.abc.project.directory.SomeClass

I've checked my MANIFEST.MF:

Manifest-Version: 1.0
Main-Class: com.abc.project.directory.SomeClass

Which has that exactly. The main class I selected to build the artifact off of is also 'com.abc.project.directory.SomeClass' exactly. I've tried just about everything like moving the META-INF folder to the same exact directy where SomeClass.java is, using different directories, using default directories, etc. to no avail.

Not too sure where I am going wrong, any help would be great!

My project basically mirrors this functioning Hello World test below: 在此处输入图片说明

click file>export and select your option to create the final executable

the problem happens because you have created a class which is in another directory than the others.Intellij can compile the file correctly if you follow the steps

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