简体   繁体   English

如何建立一个Java小程序?

[英]How to build a java applet?

Most of the tutorials around explain how to create a java applet: create a .java file with a class, compile it with javac, put the .class somewhere, add a proper tag in the html. 周围的大多数教程都说明了如何创建Java小程序:使用类创建.java文件,使用javac进行编译,将.class放在某个地方,在html中添加适当的标记。

However, I'm not able to find anything about the best practices to build and release a complex applet, made of multiple classes and with additional libraries. 但是,我无法找到有关构建和发布由多个类和其他库组成的复杂applet的最佳实践的任何信息。 How is the build/release process for this case ? 在这种情况下,构建/发布过程如何? What is it needed to go from my java project to the final .jar to put on the web ? 从我的Java项目到最终的.jar放到网上需要什么?

I'm working with pure Eclipse, no plugins. 我正在使用纯Eclipse,没有插件。

If you are starting a new project, do not use Applets. 如果要启动新项目,请不要使用小程序。 Applets are an old technology. 小程序是一种旧技术。

There is many new ways to replace Applets, try Java Web Start for example, here is a tutorial on how to start JWS 替换Applet的方法有很多,例如尝试Java Web Start这是有关如何启动JWS的教程。

UPDATE UPDATE
After your comment, here is how to deploy a packaged applet: 发表评论后,这里是部署打包的applet的方法:
In Eclipse, create your full application usually, with at least one Applet class, lets say the full path to this class is org.test.appletproject.MyApplet , when done, from Eclipse, make Export->Jar . 在Eclipse中,通常使用至少一个Applet类创建完整的应用程序,可以说到该类的完整路径是org.test.appletproject.MyApplet ,完成后,从Eclipse制作Export->Jar

Now in the HTML page, use this tag: 现在在HTML页面中,使用以下标记:

<applet code = 'org.test.appletproject.MyApplet' 
      archive = 'AppletProject.jar', 
      width = 500, 
      height = 500 />

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

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