Java applet 作为独立的 Windows 应用程序?

发布于 2024-08-04 01:05:27 字数 110 浏览 5 评论 0原文

我有一个只能在 Windows 上运行的 Java 小程序。 (它使用第 3 方 COM 对象;它不是跨平台的。)

有没有办法在 Windows 上将 Java 小程序作为独立应用程序运行?

I have a Java applet that is meant to run only on Windows. (It uses a 3rd party COM object; it is not cross-platform.)

Is there a way to run a Java applet as a stand-alone application on Windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

感受沵的脚步 2024-08-11 01:05:27

虽然您当然可以运行它,但是 Java 作为应用程序运行的方式与作为 applet 运行的方式之间存在细微的差异。一个从 init 方法开始,另一个从 main 方法开始,启动的线程和事件队列关系有点不同。

这里有一些来自 Sun 的文档,介绍如何执行此操作。如果您使用 JApplet,情况会略有不同,但想法是相同的。

Although you can certainly run it, there are subtle differences between how Java runs as an application vs. how it runs as an applet. One starts with an init method, the other starts with a main method, and the threading and event queue relationship to startup are a bit different.

Here is some documentation from Sun on how to do it. If you are using JApplet things change slightly, but the idea is the same.

戏蝶舞 2024-08-11 01:05:27

Java applet 通常没有 main 方法。他们依赖网络浏览器来启动。

不过,您可以创建一个具有 main 方法的新类,并简单地调用小程序的 init() 和 start() 方法。

您可以查看以更好地理解小程序的生命周期。

Java applets usually don't have a main method. They rely on the webbrowser to be launched.

It is possible though that you create a new class which have a main method and simple call the init() and start() method of the applet.

You may take a look at this to understand better the life cycle of the applets.

伤痕我心 2024-08-11 01:05:27

我想 appletviewer 可能是一个选项。它是 JDK 中包含的实用程序。

I suppose the appletviewer could be an option. It is a utility included in the JDK.

怪我闹别瞎闹 2024-08-11 01:05:27

JDK 有一个 appletviewer 小程序启动器。它在 JRE 中不可用,并且其行为可能与插件略有不同。

如果提供了适当的 JNLP 文件,小程序也可以从 WebStart 运行。

The JDK has an appletviewer applet launcher. It is not available in the JRE and its behaviour may be slightly different from the PlugIn.

Also applets can be run from WebStart if an appropriate JNLP file is provided.

剩余の解释 2024-08-11 01:05:27

如果“applet”指的是独立的命令 shell Java 程序,则一个简单的批处理文件就足够了:

@rem MyApp.bat
@echo off
set JVM={{path where java.exe is located}}
set FLAGS={{optional JVM flags}}
set JARFILE={{location of your jarfile}}
%JVM%\java %FLAGS% -cp %JARFILE% {{Package}}.{{Class}} {{args...}}

将大括号 {{...}} 中的项目替换为适合您的应用程序的设置。如果一切都定义正确,双击文件资源管理器窗口中的批处理文件名将执行您的 Java 类。

If by "applet" you mean a stand-alone command shell Java program, a simple batch file should suffice:

@rem MyApp.bat
@echo off
set JVM={{path where java.exe is located}}
set FLAGS={{optional JVM flags}}
set JARFILE={{location of your jarfile}}
%JVM%\java %FLAGS% -cp %JARFILE% {{Package}}.{{Class}} {{args...}}

Replace the items enclosed in braces {{...}} with settings appopriate for your application. If everything is defined correctly, double-clicking the batchfile name in a file explorer window will execute your Java class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文