“java”、“javaw”和“javaws”之间有什么区别?
java
、javaw
和 javaws
之间有什么区别?
我发现在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
请参阅 Java 工具文档:
java
命令1/javaw
命令2javaws
命令,"Java Web Start 命令"另请参阅 JDK 9 发行说明
已弃用的 API、功能和选项:
See Java tools documentation for:
java
command1/javaw
command2javaws
command, the "Java Web Start command"See also JDK 9 Release Notes
Deprecated APIs, Features, and Options:
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.
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.
来自 http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.aix32.60%2Fuser%2Fjava.html:
我怀疑 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:
And javaws is for Java web start applications, applets, or something like that, I would suspect.
我已经检查过输出重定向是否适用于
javaw
:这意味着,如果 Java 应用程序通过 System.out 或 System.err 打印出任何内容,则会将其写入这些文件,就像使用 java (没有
w
)。特别是在启动java
时,JRE 可能会在错误输出管道上写入启动错误(未找到类)。在这方面,了解错误至关重要。我建议在调用javaw
的任何情况下都使用控制台重定向。相反,如果您使用
Windows 控制台
start
命令,控制台输出重定向不适用于java
或javaw
。解释为什么会这样:我认为 javaw 在操作系统中打开一个内部进程(使用 java.lang.Process 类就足够了),并将已知的输出重定向传输到该进程。如果命令行上没有给出重定向,则不会重定向任何内容,并且
javaw
的内部启动进程不会有任何控制台输出。 java.lang.Process 的行为类似。虚拟机也可以将这个内部功能用于javaw
。如果您使用“start”,Windows 控制台会创建一个新进程供 Windows 在启动后执行命令,但不幸的是,此机制不会为已启动的子进程使用给定的重定向。
I have checked that the output redirection works with
javaw
: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 startingjava
, 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 ifjavaw
is invoked.In opposite if you use
With the Windows console
start
command, the console output redirection does not work withjava
nor withjavaw
.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 forjavaw
doesn't have any console outputs. The behavior for java.lang.Process is similar. The virtual machine may use this internal feature forjavaw
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.