java vs javaw vs javaws

Last modified on August 1st, 2014 by Joe.

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.

Comments on "java vs javaw vs javaws"

  1. Sudheer says:

    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. Anonymous says:

    very nice……

  3. Bharani says:

    Simple and Elegant Joe.

  4. Khaleel says:

    Excellent JOB !!!

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

    Thanks
    Khaleel

  5. Manishkumar Modi says:

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

  6. Anonymous says:

    This is great!

    Thanks,
    Vinayak

  7. Thilina Gallage says:

    Amazing explanation !

    Keep up the good work Joe…

  8. shubham says:

    good explanation

  9. Githin says:

    it was a new knowledge.
    thanks

  10. Samatha says:

    Very nicely put. Thanks.

  11. Rashi Coorg says:

    Very nice one! Thanks a lot.

  12. Sandeep Singh says:

    Thanks .. Nice explanation

  13. Prasad says:

    Thanks for this valuable information.

  14. Mukesh kumar Singh says:

    Hello..

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

  15. Anonymous says:

    Simply fantastic …

  16. Jayani says:

    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

  17. kruthi says:

    Find it very interesting……….

  18. Raj says:

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

  19. Anonymous says:

    very nice …….

  20. S L N V Praveen says:

    useful info Joe…!!!

  21. subash says:

    nice…
    i know something..
    thanx….

  22. Misge says:

    Nice to know I can use jvm.dll .

  23. Krisk says:

    So no javaw under Linux….

    Nice blog, keep posting!

  24. Anonymous says:

    nice blog and v usefull…..

  25. Jegadeesh says:

    Nice..

  26. Subrat says:

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

  27. ravi suthar says:

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

  28. Someone says:

    Very Good Information…

    Thanks

  29. ravi says:

    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?

  30. gefei says:

    Nice article! Thanks

  31. Martin says:

    Good one, especially javaws part.

  32. ritesh singh says:

    Very useful.

  33. Anonymous says:

    very useful

    Could you please explain javaws with one example

  34. Raks says:

    Good one Joe…

  35. Jyoti says:

    Good useful Info Joe…

  36. parthimahesh says:

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

    thanks

  37. Vijendra Yadav says:

    Hey Joe,

    Very nice explanation, and also very knowledgeable.

    Thanks

  38. Anonymous says:

    Nice.. thanks.

  39. alice says:

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

  40. Vinod Gulia says:

    This is really helpful…..

  41. Anonymous says:

    very useful info..

  42. Arun says:

    Good explanation

  43. chandan modi says:

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

  44. MD SHAUKAT ALI says:

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

  45. Shafaet says:

    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.

  46. Mubarak Ali says:

    Thanks Joe.

  47. Santhosh Reddy says:

    Very good Joe, thank you very much…

  48. Anonymous says:

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

  49. Vinay says:

    Excellent work … Good Explanation….

  50. Murugesh says:

    Good explanation

  51. SIVAKUMAR.J says:

    Dear All,

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

  52. Satya says:

    It explains very simple.

  53. Mike says:

    Thank You Joe.

    Those that really know can explain with clear simplicity.

  54. Pankaj Sinha says:

    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.

  55. Rajesh Kumar says:

    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…

  56. @ramesh says:

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

  57. Suyash says:

    Hi,

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

    Regards,
    Suyash Bhalekar

  58. Manoj Kumar says:

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

  59. Amit says:

    Simply superb !!

  60. Manoj Sharma says:

    Nice one.
    Its a very helpful for me.

    Thanks a lot Joe.

  61. Anonymous says:

    very nice explanation

  62. Abhay says:

    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.

  63. Omkar says:

    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.

  64. Omkar says:

    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?

  65. […] JVM launches in client mode. To launch in server mode just use “- server” when we run java tool […]

  66. Pravin Jose says:

    Thanks for the nice explanation.

  67. Yadav Kar says:

    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.

  68. naveen says:

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

  69. Somdev says:

    Nice explanation.

  70. ranga says:

    jnlp file should be describe the main method where it is in java class.

    Example….

    ButtonDemo
    The Java(tm) Tutorial

    ButtonDemo
    Demonstrates use of buttons within containers

    above code save into Buttondemo.jnlp and then

    in command prompt use like this > javaw ButtonDemo.jnlp then enter then u will get application.

  71. Naveen says:

    i can understand about java.exe javaw.exe tools.try to give the example for javaws.exe tool where it will be used?

  72. Naveen says:

    very good stuff.Very nice explanation

  73. Neeraj says:

    Hi Joe,

    I am working on making java application to java web start. I need functionality that each time when application gets loaded from target selection application launcher(Simple java application to select target from various target servers) should create new shortcut and replace existing one to point to new JNLP file.

    Can you please help me, how to do this?

    Thanks in advance,
    Neeraj

Comments are closed for "java vs javaw vs javaws".