编译器正在创建额外的类文件,其中包含 $ [英] Compiler is creating extra class files with $ in them

查看:27
本文介绍了编译器正在创建额外的类文件,其中包含 $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Eclipse,并且我已经使用 SWT 编写了一个 Java 应用程序.当 Eclipse 编译我的程序时,它将我的主文件重命名为 4 个不同的文件,如下所示:

  • MainFile.class
  • MainFile$1.class
  • MainFile$2.class
  • MainFile$3.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:

  • MainFile.class
  • MainFile$1.class
  • MainFile$2.class
  • MainFile$3.class

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆