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.
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 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 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 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 are closed for "java vs javaw vs javaws".
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..
very nice……
Simple and Elegant Joe.
Excellent JOB !!!
Can you write a topic on how to design/write API for a new application or product?
Thanks
Khaleel
Very Nice…
I have run above Swing GUI application using java.exe and javaw.exe
Now I got the clear picture..
Very nice,, Awesome
This is great!
Thanks,
Vinayak
Amazing explanation !
Keep up the good work Joe…
good explanation
it was a new knowledge.
thanks
Very nicely put. Thanks.
Very nice one! Thanks a lot.
Thanks .. Nice explanation
Thanks for this valuable information.
Hello..
javaw not work properly please if it is possible write the command lines.
Simply fantastic …
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
Find it very interesting……….
I am a beginner and I really understand the way you explain the concepts. Good job! Thanks a lot
very nice …….
useful info Joe…!!!
nice…
i know something..
thanx….
Nice to know I can use jvm.dll .
So no javaw under Linux….
Nice blog, keep posting!
nice blog and v usefull…..
Nice..
Nice explanation..I didn’t know why we are using javaws.Got the clear picture.
Thanks man!!!!
Good job keep it up!!:)
when i execute my jar file. i saw javaw.exe is running in my task manager.
Very Good Information…
Thanks
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?
Nice article! Thanks
Good one, especially javaws part.
Very useful.
very useful
Could you please explain javaws with one example
Good one Joe…
Good useful Info Joe…
hi,
it’s useful one.i understand differents between these and purpose.
thanks
Hey Joe,
Very nice explanation, and also very knowledgeable.
Thanks
Nice.. thanks.
this is useful. actually i also writing about core java with easy language .i like the way you explained the thing
This is really helpful…..
very useful info..
Good explanation
one word……….awesom……….joe…………….keep it up
I love JOSHEP and MKYONG…..realy a great contribution to help new lovers of java
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.
Thanks Joe.
Very good Joe, thank you very much…
u explained very nicely. I never knew this things in java. Thanks a ton!
Excellent work … Good Explanation….
Good explanation
Dear All,
This blog is very usefull to students,java developers,mobile applications developers,java faculty,etc.
Keep updating many information.
It explains very simple.
Thank You Joe.
Those that really know can explain with clear simplicity.
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.
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…
could you please give me an example of how javaws is used.
Hi,
Great work!!!!
This blogs seems to be very helpful to collect all the basic and advance knowledge of JAVA.
Regards,
Suyash Bhalekar
What kind of person you are, I feel blessed wberytime I go through your blogs.. Thanks a lot for being there for us.
Simply superb !!
Nice one.
Its a very helpful for me.
Thanks a lot Joe.
very nice explanation
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.
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.
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?
[…] JVM launches in client mode. To launch in server mode just use “- server” when we run java tool […]
Thanks for the nice explanation.
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.
Thank you. This was of help to me. Keep up the good work.
Nice explanation.
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.
i can understand about java.exe javaw.exe tools.try to give the example for javaws.exe tool where it will be used?
very good stuff.Very nice explanation
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