Mac终端:找不到或加载主类CLASSNAME [英] Mac Terminal: Could not find or load main class CLASSNAME
问题描述
错误:找不到或加载主类(MY CLASSNAME)
我用Eclipse编译了这个应用程序,当我用Eclipse ,它工作正常。
此外,我在正确的目录,当我在终端中键入ls时,它列出所有文件,包括我正在尝试运行的类文件。
这是我键入的:
java mainClass
pre>
我非常感谢帮助解决这个问题!
谢谢,
Dean
编辑:解决方案 - 而不是java mainClass,它也必须包装:java startPackage.mainClass
解决方案首先确保您位于顶级
之上的目录包
如果该类属于
包
com.foo.bar
你想要在com
之上的目录中。
在你的情况下,你想要在上面的目录
startPack
。
然后,您需要使用完全限定名来运行类...
java statPack.mainClass
例如...
I am trying to run a java program through the Terminal on Mac, yet getting:
Error: Could not find or load main class (MY CLASSNAME)
I compiled this application with Eclipse, and when I run this with Eclipse, it works fine. Furthermore, I am in the right directory, as when I type "ls" in the Terminal, it lists all the files, includes the class file I am trying to run.
This is what I type:
java mainClass
I would very much appreciate help to solve this!
Thank you,
Dean
EDIT: Solution - instead of java mainClass, it must have package too: java startPackage.mainClass
解决方案Start by making sure you are at the directory above the top level
package
If the class belongs to the
package
com.foo.bar
, you want to be in the directory abovecom
.In your case, you want to be in the directory above
startPack
.Then you need to use the fully qualified name to run the class...
java statPack.mainClass
For example...
这篇关于Mac终端:找不到或加载主类CLASSNAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!