小程序code标签和类文件 [英] Applet code tags and class files
问题描述
我刚开始写Applet和我对与包HTML Applet标记一些问题,和类文件。
我会包开始。我一直在使用NetBeans为code我的小程序,它会自动包含一个包。小应用程序运行在Netbeans的applet浏览器的罚款,并在HTML中显示一切应该除了小程序 - 但只是一个白盒子,上面写着错误。当我使用Eclipse,而不包重新编译,HTML显示applet的罚款。我什么都试过了我能想到的,但我不能为我的生命得到小程序与包工作。
<小程序code =myClass.classWIDTH =500HEIGHT =500><小程序code =myPackage.myCLass.classWIDTH =500HEIGHT =500><小程序code =mypackage的\\ myClass.classWIDTH =500HEIGHT =500>
毫无效果。所以,我的第一个问题是:什么都要我的HTML applet标记路径,以获得到包含在一个包中的小程序说呢?老实说,我所有的谷歌搜索初见成效,我听不太懂,因为我不是100%肯定一个包是什么/做。
这给我们带来我的下一个问题:类文件。 applet标记指向一个类文件,即编译源文件。编译一个.java文件创建一个.class文件,够简单。但是,我们如何从applet的java文件,一个小程序类文件得到什么?试图通过命令行编译或任何IDE失败,因为没有主要方法。到目前为止,我已经能够得到一个Applet类文件的唯一方法是使用Netbean的applet浏览器或在Eclipse运行作为applet编译code两种。有另一种方式来获得类文件?还是我用一个小程序模拟器(因为缺乏一个更好的词)来编译?
<小程序code =mypackage的。 myCLass.classWIDTH =500HEIGHT =500>
至于小程序
在 mypackage的 MyClass的
Applet类元素code>包。
1)小程序
元素应该有属性之间的空间(我不知道这是W3C建议的一部分,但它只是看起来怪异)。
<小程序code =myPackage.myCLass.classWIDTH =500HEIGHT =500 >
2) code
属性应该是类的完全合格的名字,意思是:
<小程序code =myPackage.myCLassWIDTH =500HEIGHT =500>
3)由于没有档案,没有指定codeBase类中,JRE将寻求从该HTML是目录 mypackage的
子目录类加载。例如。如果HTML被称为 applet.html
和位于:
类将需要位于:
一旦你认为你有Applet类正确,请尝试使用在浏览器地址栏中的地址获取它。如果该类没有下载提供,则JRE将无法要么加载它
I just started writing Applets and I had some questions about the HTML applet tags with packages, and class files.
I'll start with packages. I've been using Netbeans to code my applets, which includes a package automatically. The applet runs fine in the Netbeans applet viewer, and the HTML is displaying everything it should except the applet - there's just a white box that says "Error." When I re-compiled using Eclipse without the package, the HTML display the applet fine. I tried everything I could think of, but I could not for the life of me get the applet to work with the package.
<applet code="myClass.class"width="500"height="500">
<applet code="myPackage.myCLass.class"width="500"height="500">
<applet code="myPackage\myClass.class"width="500"height="500">
Nothing worked. So, my first question is this: what should my HTML applet tag path say in order to get to an applet which is contained in a package? Honestly, all of my google searches yielded results that I didn't really understand, as I'm not 100% sure what a package is/does.
Which brings us to my next question: class files. The applet tag points a a class file, i.e., a compiled source file. Compiling a .java file creates a .class file, simple enough. But how does one get from an applet java file to an applet class file? Attempting to compile via the command line or any IDE fails, because there's no main method. So far, the only way that I've been able to get a class file for an applet is to compile the code either using Netbean's applet viewer or "Run as an applet" in Eclipse. Is there another way to obtain the class file? Or do I have to compile using an applet emulator (for lack of a better word)?
<applet code="myPackage.myCLass.class"width="500"height="500">
As to the applet
element for a myClass
applet class in the myPackage
package.
1) An applet
element should have spaces between the attributes (I'm not sure if that is part of the W3C recommendation, but it just looks weird).
<applet code="myPackage.myCLass.class" width="500" height="500">
2) The code
attribute should be the fully qualified name of the class, which means:
<applet code="myPackage.myCLass" width="500" height="500">
3) With no archives and no codebase specified, the JRE would look for the class in the myPackage
sub-directory of the directory from which the HTML is loaded. E.G. if the HTML is called applet.html
and is located at:
The class would need to be located at:
Once you think you have the applet class correct, try fetching it using the address in the browser address bar. If the class is not offered for download, the JRE won't be able to load it either.
这篇关于小程序code标签和类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!