编译器正在创建额外的类文件$ [英] Compiler is creating extra class files with $ in them
问题描述
我使用Eclipse,我使用SWT编写了一个Java应用程序。当Eclipse编译我的程序时,它将我的主文件重命名为4个不同的文件,如下所示:
- MainFile.class
- MainFile $ 1.class
- MainFile $ 2.class
- MainFile $ 3.class
- MainFile.class
- MainFile$1.class
- MainFile$2.class
- MainFile$3.class
当我从命令行运行这个程序时,我得到
main class:MainFile.class。程序将退出。
我真的不明白为什么会发生这种情况。
我们能看到你运行的命令行吗?您可能需要写 java MainFile
而不是 java MainFile.class
。
I'm using Eclipse and I've written a Java application using SWT. When Eclipse compiles my program, it renames my main file into 4 different files like this:
When I go to run this program from command line, I get
Could not find the main class: MainFile.class. Program will exit.
I really don't understand why this is happening.
The $
classes are for anonymous inner classes and perfectly normal.
Could we see the command line you ran? You probably need to write java MainFile
instead of java MainFile.class
.
这篇关于编译器正在创建额外的类文件$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!