[英]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.我正在使用 IntellIj 尝试从我的程序中创建一个可运行的 Jar。 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:
我已经得到了一个可运行的 jar,可以在 cmd 中为一个简单的 hello world 程序正确执行,但是当我尝试为更大的项目执行相同的确切步骤时,我得到了错误:
Error: Could not find or load main class com.abc.project.directory.SomeClass
错误:无法找到或加载主类 com.abc.project.directory.SomeClass
I've checked my MANIFEST.MF:我检查了我的 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.
我选择用来构建工件的主要类也是“com.abc.project.directory.SomeClass”。 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.
我已经尝试了几乎所有的事情,比如将 META-INF 文件夹移动到 SomeClass.java 所在的同一目录、使用不同的目录、使用默认目录等,但都无济于事。
Not too sure where I am going wrong, any help would be great!不太确定我哪里出错了,任何帮助都会很棒!
My project basically mirrors this functioning Hello World test below:我的项目基本上反映了下面这个功能正常的 Hello World 测试:
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出现问题是因为您创建了一个类,该类位于另一个目录中而不是其他目录中。如果您按照以下步骤操作,Intellij 可以正确编译该文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.