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

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

问题描述

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




  • 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:

    • 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天全站免登陆