java vs javaw vs javaws

07/08/2012

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.

Ads by Google

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.

This Core Java tutorial was posted on 07/08/2012.
Ads by Google

69 comments on “java vs javaw vs javaws

  1. Good one…..I saw javaw.exe in the task manager and kind of knew that it is associated with eclipse process. Now I got clear picture..

  2. Excellent JOB !!!

    Can you write a topic on how to design/write API for a new application or product?

    Thanks
    Khaleel

  3. Very Nice…
    I have run above Swing GUI application using java.exe and javaw.exe
    Now I got the clear picture..
    Very nice,, Awesome

  4. Amazing explanation !

    Keep up the good work Joe…

  5. Hello..

    javaw not work properly please if it is possible write the command lines.

  6. Hi Joe, your blogs are really nice and very helpful indeed. I am studying design patterns since last few days and I often refer to your blogs. Thank you for sharing this information

  7. I am a beginner and I really understand the way you explain the concepts. Good job! Thanks a lot

  8. So no javaw under Linux….

    Nice blog, keep posting!

  9. Nice explanation..I didn’t know why we are using javaws.Got the clear picture.
    Thanks man!!!!
    Good job keep it up!!:)

  10. when i execute my jar file. i saw javaw.exe is running in my task manager.

  11. How can we close a program that was executed through javaw. for example if I made a program and it is running irrespective of console being open or close. how to kill that process?

  12. very useful

    Could you please explain javaws with one example

  13. hi,
    it’s useful one.i understand differents between these and purpose.

    thanks

  14. Hey Joe,

    Very nice explanation, and also very knowledgeable.

    Thanks

  15. this is useful. actually i also writing about core java with easy language .i like the way you explained the thing

  16. one word……….awesom……….joe…………….keep it up

  17. I love JOSHEP and MKYONG…..realy a great contribution to help new lovers of java

  18. This blog is one of the best blogs i’ve seen on internet. Though Java is not my subject of interest,this site helped me a lot to learn design patterns,thank you mr joe.

  19. u explained very nicely. I never knew this things in java. Thanks a ton!

  20. Dear All,

    This blog is very usefull to students,java developers,mobile applications developers,java faculty,etc.
    Keep updating many information.

  21. Thank You Joe.

    Those that really know can explain with clear simplicity.

  22. I enjoy reading your posts. Thanks a lot for sharing it with all of us. Could you please share some interesting facts related to jdbc.

  23. Hi Joe,
    Could you please elaborate the part jnlp_url from javaws.exe. Actually I am working on a java web start application which does not have .jnlp file. And it also does not contain main() method. Then how the deployment can be done? Any help will be appreciated! Thanks in Advance…

  24. could you please give me an example of how javaws is used.

  25. Hi,

    Great work!!!!
    This blogs seems to be very helpful to collect all the basic and advance knowledge of JAVA.

    Regards,
    Suyash Bhalekar

  26. What kind of person you are, I feel blessed wberytime I go through your blogs.. Thanks a lot for being there for us.

  27. Nice one.
    Its a very helpful for me.

    Thanks a lot Joe.

  28. Thanks Joe… this was a life saver. Even after using Java for such a long time, I never knew the difference.
    I had to write a program that would run in the background but still interact with the UI. Instead of creating complicated services and a different UI, this helped me achieve my goal in 30 sec.
    I owe you a beer.

  29. Could you please give me an example of how to use javaws like javaw?
    Because i didn’t get the clarity with javaws than javaw.

  30. I saw.. java.exe, javaw.exe, javaws.exe
    in both jdk/bin and jre/bin directories.
    As per my understanding jdk is a development kit
    that’s why it contains the java compiler javac.exe.
    and JRE is the runtime environment
    having the JVM in the form of java.exe.
    So, but why java.exe is also in jdk/bin folder?
    could you please clarify me?

  31. Pingback: JVM Server vs Client Mode

  32. Hi Joe,
    i Am facing a wired problem while launching Dynamic JNLP from JSP.

    Every time the web application launches JNLP from JSP, it creates a new javaw*32 process in task manager.

    if a user has launched it 30 times, then we can see 30 javaw*32 processes in task manager.
    It causes the application freeze sometime.
    Could you please suggest us How to handle this scenario.

    Note: If i would use system.exit(0) in finally block of jsp then i think i will kill the process of application itself.

  33. Thank you. This was of help to me. Keep up the good work.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>