Java类文件filename $ 1.class ... etc问题 [英] Java Class Files filename$1.class... etc Question

查看:163
本文介绍了Java类文件filename $ 1.class ... etc问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成功创建一些小程序后,我将它们嵌入到一个网页中,发现所有的类文件都必须包含在内。



在Applet的多次迭代之后,有几个类文件:

filename .class

filename $ 1.class

filename $ 2.class等。



我试着只使用 filename .class,试过最后一个,尝试第一个和最后一个...但是,正如我所说,所有的类文件必须



问题:

1)文件名 $ n.class(n =一些数)文件似乎是在Eclipse的whim创建 - 是否有这个解释(我搜索w / o成功)?



2)即使类文件只有〜4kb,我如何做一个清理,例如吹走所有的文件名 $ n



感谢

>

解决方案

这些类是从您的applet中创建的匿名类创建的 - 很可能是事件侦听器等。



他们将被其他编译器创建(也许用其他名字)。



如果你真的想要避免它们,其他内部)类。但是这个结果往往是一个丑陋的风格,所以不建议这样做。



如果你不想将所有的个别类文件上传到服务器浏览器必须单独获取它们),请考虑将它们全部放在一个jar文件中,并在applet标记中引用它。


After successfully creating some applets, I embedded them in a webpage and discovered that ALL the class files must be included. Leave one out and it won't work.

After several iterations of an Applet, there are several class files:
filename.class
filename$1.class
filename$2.class, etc.

I tried using only the filename.class, tried just the last one, tried the first and last... but, as I said, all the class files must be included for the webpage.

Question(s):
1) The filename$n.class (n=some number) files seem to be created at the whim of Eclipse - is there an explanation of this (I searched w/o success)?

2) Even though the class files are only ~4kb, How do I do a cleanup such as to blow away all the filename$n.class files and still be able to embed in a webpage?

Any recommendations?

Thanks

解决方案

These classes are created from anonymous classes created in your applet - most likely event listeners and such.

They would be created (maybe with other names) by other compilers, too.

If you really want to avoid them, program without anonymous (and other inner) classes. But this results often in an ugly style, so this is not recommended.

If you don't want to upload all the individual class files to the server (and then the browsers having to fetch them all individually), think about putting them all in one jar file, and referencing this in your applet-tag.

这篇关于Java类文件filename $ 1.class ... etc问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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