“java”、“javaw”和“javaws”之间有什么区别?

发布于 2024-12-16 19:52:26 字数 136 浏览 3 评论 0原文

javajavawjavaws 之间有什么区别?

我发现在 Windows 上大多数 Java 的使用都是使用 javaw 完成的。

What is the difference between java, javaw, and javaws?

I have found that on Windows most usage of Java is done using javaw.

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

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

发布评论

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

评论(5

2024-12-23 19:52:27

请参阅 Java 工具文档:

  1. java 工具启动 Java 应用程序。它通过启动 Java 运行时环境、加载指定的类并调用该类的 main 方法来实现此目的。
  2. javaw 命令与 java 相同,只是 javaw 没有关联的控制台窗口。当您希望显示命令提示符窗口时,请使用javaw

javaws 命令启动 Java Web Start,它是 Java 网络启动协议 (JNLP) 的参考实现。 Java Web Start 启动托管在网络上的 Java 应用程序/小程序。

如果指定了 JNLP 文件,javaws 将启动 JNLP 文件中指定的 Java 应用程序/小程序。

javaws 启动器有一组当前版本支持的选项。但是,这些选项可能会在未来版本中删除。

另请参阅 JDK 9 发行说明
已弃用的 API、功能和选项

Java 部署技术已弃用,并将在未来版本中删除
Java Applet 和 WebStart 功能,包括 Applet API、Java 插件、Java Applet Viewer、JNLP 和 Java Web Start,包括 javaws 工具,全部都是< strong>在 JDK 9 中已弃用,并将在未来版本中删除。

See Java tools documentation for:

  1. The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method.
  2. The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear.

The javaws command launches Java Web Start, which is the reference implementation of the Java Network Launching Protocol (JNLP). Java Web Start launches Java applications/applets hosted on a network.

If a JNLP file is specified, javaws will launch the Java application/applet specified in the JNLP file.

The javaws launcher has a set of options that are supported in the current release. However, the options may be removed in a future release.

See also JDK 9 Release Notes
Deprecated APIs, Features, and Options
:

Java Deployment Technologies are deprecated and will be removed in a future release
Java Applet and WebStart functionality, including the Applet API, the Java plug-in, the Java Applet Viewer, JNLP and Java Web Start, including the javaws tool, are all deprecated in JDK 9 and will be removed in a future release.

浮生面具三千个 2024-12-23 19:52:27

java: Java 应用程序执行器,与控制台关联以显示输出/错误

javaw:Java 窗口)应用程序执行器与控制台不关联。所以没有显示输出/错误。它可用于以静默方式将输出/错误推送到文本文件。它主要用于启动基于 GUI 的应用程序。

javaws: (Java web start) 下载并运行分布式 Web 应用程序。同样,没有关联任何控制台。

所有这些都是 JRE 的一部分并使用相同的 JVM。

java: Java application executor which is associated with a console to display output/errors

javaw: (Java windowed) application executor not associated with console. So no display of output/errors. It can be used to silently push the output/errors to text files. It is mostly used to launch GUI-based applications.

javaws: (Java web start) to download and run the distributed web applications. Again, no console is associated.

All are part of JRE and use the same JVM.

尘曦 2024-12-23 19:52:27

java.exe 与控制台关联,而 javaw.exe 没有任何此类关联。因此,当运行java.exe时,它会自动打开一个命令提示符窗口,其中显示输出和错误流。

java.exe is associated with the console, whereas javaw.exe doesn't have any such association. So, when java.exe is run, it automatically opens a command prompt window where output and error streams are shown.

无远思近则忧 2024-12-23 19:52:27

来自 http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.aix32.60%2Fuser%2Fjava.html

javaw 命令与 java 相同,只是 javaw 没有关联的控制台窗口。当您不希望显示命令提示符窗口时,请使用 javaw。如果失败,javaw 启动器会显示一个包含错误信息的窗口。

我怀疑 javaws 适用于 Java Web Start 应用程序、小程序或类似的东西。

From http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.aix32.60%2Fuser%2Fjava.html:

The javaw command is identical to java, except that javaw has no associated console window. Use javaw when you do not want a command prompt window to be displayed. The javaw launcher displays a window with error information if it fails.

And javaws is for Java web start applications, applets, or something like that, I would suspect.

霊感 2024-12-23 19:52:27

我已经检查过输出重定向是否适用于 javaw

javaw -cp ... mypath.MyClass ... arguments 1>log.txt 2>err.txt

这意味着,如果 Java 应用程序通过 System.out 或 System.err 打印出任何内容,则会将其写入这些文件,就像使用 java (没有 w)。特别是在启动 java 时,JRE 可能会在错误输出管道上写入启动错误(未找到类)。在这方面,了解错误至关重要。我建议在调用 javaw 的任何情况下都使用控制台重定向。

相反,如果您使用

start java .... 1>log.txt 2>err.txt

Windows 控制台 start 命令,控制台输出重定向不适用于javajavaw

解释为什么会这样:我认为 javaw 在操作系统中打开一个内部进程(使用 java.lang.Process 类就足够了),并将已知的输出重定向传输到该进程。如果命令行上没有给出重定向,则不会重定向任何内容,并且 javaw 的内部启动进程不会有任何控制台输出。 java.lang.Process 的行为类似。虚拟机也可以将这个内部功能用于javaw

如果您使用“start”,Windows 控制台会创建一个新进程供 Windows 在启动后执行命令,但不幸的是,此机制不会为已启动的子进程使用给定的重定向。

I have checked that the output redirection works with javaw:

javaw -cp ... mypath.MyClass ... arguments 1>log.txt 2>err.txt

It means, if the Java application prints out anything via System.out or System.err, it is written to those files, as also with using java (without w). Especially on starting java, the JRE may write starting errors (class not found) on the error output pipe. In this respect, it is essential to know about errors. I suggest to use the console redirection in any case if javaw is invoked.

In opposite if you use

start java .... 1>log.txt 2>err.txt

With the Windows console start command, the console output redirection does not work with java nor with javaw.

Explanation why it is so: I think that javaw opens an internal process in the OS (adequate using the java.lang.Process class), and transfers a known output redirection to this process. If no redirection is given on the command line, nothing is redirected and the internal started process for javaw doesn't have any console outputs. The behavior for java.lang.Process is similar. The virtual machine may use this internal feature for javaw too.

If you use 'start', the Windows console creates a new process for Windows to execute the command after start, but this mechanism does not use a given redirection for the started sub process, unfortunately.

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