Compiler is creating extra class files with $ in them

冷暖自知 提交于 2019-12-20 05:21:14

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10786842/compiler-is-creating-extra-class-files-with-in-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!