且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

运行我的程序时,Java 无法找到或加载主类

更新时间:2023-11-20 09:49:10

当我编译你提供的代码时

When I compile the code you provided with

javac a1_13132334.java

然后用

java a1_13132334 temp.txt

我可以很好地看到程序输出(好吧,至少我得到了一个数字格式异常).我会说确保你在编译后检查你的 .class 文件并确保你在正确的目录中.

I can see the program output just fine (well, I get a number format exception at least). I'd say make sure you check for your .class file after you compile and make sure you're in the correct directory.

也许可以尝试将您的代码示例放在一个新文件中,而不在新位置使用 netbeans,然后尝试编译并运行它.

Perhaps try taking your code example and putting it in a new file without using netbeans in a new location and try compiling and running that.

如果这没有帮助,您可以参考:Java 找不到主类

You could refer to this if this doesn't help: Java can't find main class