[英]Java could not find or load main class error
For some reason, I can't get java to run my program. 由于某种原因,我无法让Java运行程序。 Whenever I try I get the message
每当我尝试我都会收到消息
"Error: Could not find or load main class Project"
“错误:找不到或加载主类项目”
In Command Prompt I type cd Documents
since the file is in my Documents folder, type 在命令提示符下,输入
cd Documents
因为该文件位于我的Documents文件夹中,请键入
javac Project.java
then 然后
java Project
to try and run it but I get the above error message. 尝试运行它,但出现上述错误消息。
import java.util.Scanner;
import java.text.DecimalFormat;
public class Project
{
public static void main(String[] args)
{
Code and stuff
}
}
There's a fair bit of code that I left out but I think this is the part that's messed up. 我遗漏了一些代码,但是我认为这是一团糟。 Let me know if you need to see the rest of the code and I'll edit this.
让我知道是否需要查看其余的代码,我将对其进行编辑。
Change 更改
java Project
to (assuming Project.class
is in your current folder) 到(假设
Project.class
在当前文件夹中)
java -cp . Project
as it is, you aren't setting a class-path. 照原样,您没有设置类路径。
You have add the path of .class files in classpath during execution 您在执行期间已将.class文件的路径添加到classpath中
Run following command: 运行以下命令:
java -classpath C:\Users\DELL\Documents Project
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.