简体   繁体   English

在Eclipse之外运行Java Applet

[英]Running Java Applet Outside Eclipse

I have written a Java applet in Eclipse. 我已经在Eclipse中编写了Java小程序。 How do I run it outside eclipse, or an another computer that doesn't have Eclipse? 如何在Eclipse或另一台没有Eclipse的计算机上运行它? Will a runnable JAR File work on a non-local file system? 可运行的JAR文件是否可以在非本地文件系统上工作?

If you want a runnable jar with a main method, you use JFrame rather than an Applet 如果您希望使用具有main方法的可运行jar,请使用JFrame而不是Applet

Also, find a more current tutorial. 另外,找到最新的教程。 Think of awt as mostly deprecated (except for event handling and drawing). 认为awt几乎已被弃用(事件处理和绘图除外)。 You should be using swing for UI. 您应该为用户界面使用swing。

If you want to put it in a browser, you use a JApplet (the swing equivalent of Applet). 如果要将其放在浏览器中,请使用JApplet(相当于Applet的秋千)。

If you want to run a jar file via command line, use java -jar myJarFile.jar 如果要通过命令行运行jar文件,请使用java -jar myJarFile.jar

Often you can just double-click it. 通常,您可以双击它。

Make sure you exported as runnable jar. 确保导出为可运行的jar。 If there's no main class specified in the manifest you can also do 如果清单中没有指定主类,您也可以

java -cp myJarFile.jar main.MainClass java -cp myJarFile.jar main.MainClass

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

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