简体   繁体   English

如何将在Eclipse中制作的小程序转换为可在Web浏览器中运行的小程序?

[英]How do I turn an applet I made in Eclipse into something that will run in a web browser?

How do I go from the Eclipse project to making a file that will run the applet in a browser? 如何从Eclipse项目转到制作将在浏览器中运行小程序的文件? From what I understand, I have to make it into a .jar file and then make an html file with the applet tag, like follows: 据我了解,我必须将其制作成.jar文件,然后使用applet标签制作一个html文件,如下所示:

<html>
  <body>
    <applet name="TerisApplet.java" code = "TetrisApplet.jar">
    </applet>
  </body>
</html>

I do this and I run into nothing but trouble. 我这样做了,除了麻烦我什么都没有。 Right now I am receiving a ClassNotFoundException. 现在,我收到ClassNotFoundException。 What am I doing wrong? 我究竟做错了什么?

If someone can walk me through step by step from getting the Java Applet from Eclipse into an applet running over a browser, that would be awesome. 如果有人可以逐步引导我完成从Eclipse到Java Applet到通过浏览器运行的Applet的开发,那将是很棒的。 This is for my own learning experience btw and not for school. 这是出于我自己的学习经历,而不是为了学校。 I'm pretty good with Java I think but fairly new to applets. 我认为我对Java相当满意,但是对于applet来说还很陌生。

1) the code should be 1)代码应为

<html>
    <body>
       <applet code="name.class"
                       width="500"
                        height="250"/>
       </body>
   </html>

2) you must add your .class file to the folder in which your html file is located for this just search your name.class file and ther would be two files one with a $ sign , copy them both to the folder which contains your .html file 2)您必须将.class文件添加到html文件所在的文件夹中,只需搜索您的name.class文件,则这将是两个带有$符号的文件,将它们都复制到包含您的的文件夹中。 html文件

In "name.class","name" means your class name and you can take width and height as you want this is just an example. 在“ name.class”中,“ name”表示您的类名,您可以根据需要选择宽度和高度,这只是一个示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM