`
ihyperwin
  • 浏览: 425572 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

java vs javaw vs javaws

 
阅读更多

reference:http://javapapers.com/core-java/java-vs-javaw-vs-javaws/

 

This article gives an awareness tip. Do you know the difference between java, javaw and javaws tools. All these three are java application launchers. We know well about java.exe which we use quite often. Our command line friend, mostly we use it for convenience to execute small java programs. javaw is rare for us. Sometimes we have seen that in running application list in windows task manager. javaws is web start utility.

jvm.dll

We need to know about jvm.dll also. This is the actual java virtual machine implementation in windows environment and it is part of the JRE. A ‘C’ program can use this jvm.dll directly to run the jvm.

java.exe

java.exe is a Win32 console application. This is provided as a helper so that, instead of using jvm.dll we can execute java classes. As it is a Win32 console application, obviously it is associated with a console and it launches it when executed.

 

javaw.exe

javaw.exe is very similar to java.exe. It can be considered as a parallel twin. It is a Win32 GUI application. This is provided as a helper so that application launches its own GUI window and will not launch a console. Whenever we want to run a GUI based application and don’t require a command console, we can use this as application launcher. For example to launch Eclipse this javaw.exe is used. Write a small java hello world program and run it as “javaw HelloWorld” using a command prompt. Silence! nothing happens then how do I ensure it. Write the same using Swing and execute it you will see the GUI launched. For the lazy to ensure that it is same as java.exe (only difference is console) “javaw HelloWorld >> output.txt”. It silently interprets and pushes the output to the text file.

import javax.swing.*;
 
public class HelloWorldSwing {
    private static void createAndShowGUI() {
        JFrame jFrame = new JFrame("HelloWorld Swing");
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLabel helloLabel = new JLabel("Hello World!");
        jFrame.getContentPane().add(helloLabel);
        jFrame.pack();
        jFrame.setVisible(true);
    }
 
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

We can execute the above GUI application using both java.exe and javaw.exe If we launch using java.exe, the command-line waits for the application response till it closes. When launched using javaw, the application launches and the command line exits immediately and ready for next command.

javaws.exe

javaws.exe is used to launch a java application that is distributed through web. We have a jnlp_url associated with such application. We can use as “javaws jnlp_url” to launch the application. It downloads the application from the url and launches it. It is useful to distribute application to users and gives central control to provide updates and ensures all the users are using the latest software. When the application is invoked, it is cached in the local computer. Every time it is launched, it checks if there is any update available from the distributor.

 

 

-----------------------------------------------------------------------------华丽的分割线--------------------------------------------------------------------

如果你英文够好的话,请忽视下面吧,这个中文翻译个人感觉不是很到位,虽然加入了一些图和自己理解.

转自:http://www.myexception.cn/program/1221139.html

 

java  ,javaw   和  javaws 的区别:

 

首先,所有的这些都是java的启动装置,java.exe经常使用,当用命令行输出到window的时候,会有java.exe进程,通过任务管理器可以看到。通常 我们执行一些小的java程序的时候会有 java.exe进程在运行。javaw.exe对于我们也比较特殊,我们也能够通过任务管理器看到javaw.exe进程的运行。javaws通常web开启的时候的进程。

jvm.dll

jvm.dll是一个java虚拟机在windows平台环境上的实现,也是JRE的一部分,一个C程序能够使用jvm.dll直接运行在jvm上。

java.exe

java.exe是win32控制台应用,它提供了一种帮助,代替使用jvm.dll执行java  classes 文件,作为一个win32控制台应用,显然他是和一个控制台相关联,当执行java classes的时候,它运行。

javaw.exe

javaw.exe是相似的和java.exe  是一个win32的GUI应用,应用提供自己的GUI窗口,不启用控制台。

因此我们想运行一个GUI程序不需要命令控制台。

下面是一个例子:

 

package javaw;

import javax.swing.*;

public class HelloWorldSwing {
    private static void createAndShowGUI() {
        JFrame jFrame = new JFrame("HelloWorld Swing");
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLabel helloLabel = new JLabel("Hello World!");
        jFrame.getContentPane().add(helloLabel);
        jFrame.pack();
        jFrame.setVisible(true);
    }
 
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}


上面是一个GUI程序,按照如下方式运行就是在控制台上运行:

 

java -classpath . javaw.HelloWorldSwing

 解释:其中 -classpath .  代表把classpath 的路径设置为当前目录。

运行后查看任务管理器出现了 java.exe进程   ------ 因为这是通过控制台运行的。

图如下:



 

如果在eclipse中直接运行:运行后 查看任务管理器出现 javaw.exe进程  --因为没有通过控制台输出运行。

图如下:

 

 

如果用javaw通过命令行运行也是如上图所示:

 

注: javaw -classpath . javaw.HelloWorldSwing  启动的进程为javaw.exe

       java -classpath . javaw.HelloWorldSwing  启动的进程为java.exe

java.exe  和 javaw.exe两种运行方式的区别还有一点  java运行GUI以后堵塞在那里直到窗口关闭。

javaw运行GUI后 直接就可以进行下一条命令的运行了。

javaws.exe

javaws.exe进程适用于启动通过web 配置的程序,简而言之就是在web应用程序中应用。

总结:

java.exe用于启动window console  控制台程序

javaw.exe用于启动 GUI程序

javaws.exe用于web程序。

jvm.dll就是java虚拟机规范在windows平台上的一种实现

分享到:
评论

相关推荐

    Windows下java、javaw、javaws以及jvm.dll等进程的区别

    主要介绍了Windows下java、javaw、javaws以及jvm.dll等进程的区别,本文分别讲解了它们的作用并给出代码实例,最后做出了区别总结,需要的朋友可以参考下

    java和 javaw 及 javaws的区别解析

    主要介绍了java和 javaw 及 javaws的区别解析,本文通过实例给大家详细介绍,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

    批量关闭javaw进程

    批量结束javaw进程,使用bat批处理方式批量结束Java进程。

    java.exe和javaw.exe的区别及使用方法

    主要介绍了java.exe和javaw.exe的区别及使用方法,需要的朋友可以参考下

    javaw.exe动态链接库

    javaw.exe动态链接库,javaw.exe动态链接库,javaw.exe动态链接库

    javaw进程讲解

    学习学习!! javaw 用web开发的时候注意到的!!

    韩顺平Java视频教程全套(共95讲)

    视频共有95讲,25个G,是韩顺平老师的课程,讲的非常详细透彻,有关于基本语法的知识,也有案例的讲解,适合Java初学者同时对于想进一步提高Java编程能力的人也有帮助。资源若失效,可以联系我,QQ2891469579.

    php-java-bridge 配置包

    start javaw -jar JavaBridge.jar 保存后,双击启动 会有一个提示框选择vmbridge port 默认8080,直接点ok就行了 5.在/demo/下新建test.php内容如下: require_once ( "java/Java.inc" ); header( "content-type:...

    windows下启动java jar包的bat脚本

    windows下启动java jar包的bat脚本 javaw后台启动,jdk1.8或者更高,winserver 2016 经过测试

    java程序双击运行-双击jar文件运行程序.pdf

    2)选择JAVA虚拟机的安装⽂件夹,如果安装的是Java 7,安装⽂件夹⼀般为"C:\Program Files\Java\jre7\bin"(具体⽂件夹请⾃⾏查 找),找到javaw.exe⽂件,点击"打开"按钮。 3) 这时已经设置了使⽤javaw.exe应⽤程序来...

    javaw仓库管理系统.docx

    javaw仓库管理系统.docx

    java打包exe 更换图标

    .\java1.4.2\jre\bin\javaw.exe -jar ChatServer.jar  第一行设置指向JAR包ChatServer.jar的目录,由于launch.exe和ChatServer.jar同在一个目录,所以用“.”即当前目录。 第二行设置指向jre\bin\javaw.exe的...

    JAVA学生管理系统

    1、把6个java文件保存到同一文件夹,例如C:\Student.然后将6个java文件分别编译生成相应的字节码(.class)文件,然后,用java 解释器运行主类:C:\Student\java ... javaw -jar StudentManager.jar 保存即可。

    Javaw基础课程笔记.zip

    Java 视频教程目录: day01、Java 语言发展史_JDK的安装_HelloWorld程序的编写_关键字_标识符_基本数据类型。 day02、Java 数据类型转换_ASCII编码_各种运算符。 day03、Java 选择排序、循环结构和循环控制语句。...

    用BAT设置WINDOWS系统环境变量,如java的jdk环境变量

    classpath.bat classpath2.bat classpath2.bat java_home.bat java_home.bat,把当前路径设置为系统环境变量等。

    javaw仓库管理系统.pdf

    javaw仓库管理系统.pdf

    jar文件如何打开或者jar文件关联到java

    jar文件如何打开 jar 如何打开jar文件 jar怎么关联到java jar怎么关联到javaw jar文件如何关联到jar文件

Global site tag (gtag.js) - Google Analytics