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.

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 added on 07/08/2012.

«

»

Comments on "java vs javaw vs javaws"

  1. Naveen says:

    very good stuff.Very nice explanation

  2. 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?

  3. Somdev says:

    Nice explanation.

  4. naveen says:

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

  5. 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.

  6. Pravin Jose says:

    Thanks for the nice explanation.

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

  8. 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?

  9. 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.

  10. 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.

  11. Anonymous says:

    very nice explanation

  12. Manoj Sharma says:

    Nice one.
    Its a very helpful for me.

    Thanks a lot Joe.

  13. Amit says:

    Simply superb !!

  14. 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.

  15. 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

  16. @ramesh says:

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

  17. 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…

    • 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.

  18. 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.

  19. Mike says:

    Thank You Joe.

    Those that really know can explain with clear simplicity.

  20. Satya says:

    It explains very simple.

  21. SIVAKUMAR.J says:

    Dear All,

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

  22. Murugesh says:

    Good explanation

  23. Vinay says:

    Excellent work … Good Explanation….

  24. Anonymous says:

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

  25. Santhosh Reddy says:

    Very good Joe, thank you very much…

  26. Mubarak Ali says:

    Thanks Joe.

  27. 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.

  28. MD SHAUKAT ALI says:

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

  29. chandan modi says:

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

  30. Arun says:

    Good explanation

  31. Anonymous says:

    very useful info..

  32. Vinod Gulia says:

    This is really helpful…..

  33. alice says:

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

  34. Anonymous says:

    Nice.. thanks.

  35. Vijendra Yadav says:

    Hey Joe,

    Very nice explanation, and also very knowledgeable.

    Thanks

  36. parthimahesh says:

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

    thanks

  37. Jyoti says:

    Good useful Info Joe…

  38. Raks says:

    Good one Joe…

  39. Anonymous says:

    very useful

    Could you please explain javaws with one example

  40. ritesh singh says:

    Very useful.

  41. Anonymous says:

    Good one, especially javaws part. By the way you can also check Difference between java and javaw command.

  42. gefei says:

    Nice article! Thanks

  43. 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?

  44. Someone says:

    Very Good Information…

    Thanks

  45. ravi suthar says:

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

  46. Subrat says:

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

  47. Jegadeesh says:

    Nice..

  48. Anonymous says:

    nice blog and v usefull…..

  49. Krisk says:

    So no javaw under Linux….

    Nice blog, keep posting!

  50. Misge says:

    Nice to know I can use jvm.dll .

  51. subash says:

    nice…
    i know something..
    thanx….

  52. S L N V Praveen says:

    useful info Joe…!!!

  53. Anonymous says:

    very nice …….

  54. Raj says:

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

  55. kruthi says:

    Find it very interesting……….

  56. 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

  57. Anonymous says:

    Simply fantastic …

  58. Mukesh kumar Singh says:

    Hello..

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

  59. Prasad says:

    Thanks for this valuable information.

  60. Sandeep Singh says:

    Thanks .. Nice explanation

  61. Rashi Coorg says:

    Very nice one! Thanks a lot.

  62. Samatha says:

    Very nicely put. Thanks.

  63. Githin says:

    it was a new knowledge.
    thanks

  64. shubham says:

    good explanation

  65. Thilina Gallage says:

    Amazing explanation !

    Keep up the good work Joe…

  66. Anonymous says:

    This is great!

    Thanks,
    Vinayak

  67. 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

  68. Khaleel says:

    Excellent JOB !!!

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

    Thanks
    Khaleel

  69. Bharani says:

    Simple and Elegant Joe.

  70. Anonymous says:

    very nice……

  71. 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..

Your Comment