Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Tuesday, July 27, 2021

Difference Between java and javaw Commands from JDK

The difference between java.exe and javaw.exe commands was the recent java question asked to one of my friends. while running a java program on windows you might have noticed that they will appear in the task manager as either java.exe or javaw.exe,  also in JAVA_HOME/bin we see these two java commands java.exe and javaw.exe, do you know the difference between java.exe and javaw.exe? surprisingly not many java programmers know the answer to this java interview question, maybe because java developers have not paid enough attention to these commands. anyway here we will see few differences between java and java commands:

And, if you are serious about improving your advanced JVM skill and learn things like taking and analyzing heap dumps then highly recommend you to join Java Application Performance and Memory Management course on Udemy. 

It's one of the advanced courses for Java programmers to learn more about Performance and Memory management including troubleshooting memory leaks in Java.

java vs javaw command

difference between javaw and java commandsBoth java.exe and javaw.exe can execute java programs including jar file, the only difference is that with java.exe you have a console executed and you need to wait until your java program finishes to run any other command on the other hand in case of javaw.exe no console or window is associated with execution.

you can run your java program either by using java.exe or javaw.exe. It's suggested to use javaw.exe when you don't need a command line window to appear. javaw launcher will display in error in a dialog box if execution fails.

In the summary, the main difference between java and javaw command is that with java.exe you will get a command prompt window but with javaw.exe there is no command prompt windows associated.

Other Java interview questions you may like



Ryder said...

Another difference between java and javaw is that, java is four letter command while javaw is five letter command :)

Bob said...

java.exe can be used when you want to output text or input text from console. if you are using swing application to launch than javaw.exe is better choice just like Netbeans, Eclipse or any other java swing application.

Anonymous said...

It is really good.

srinath reddy said...

good tip. javaw.exe is the better choice than java.exe

Anonymous said...

I'm an old java1.0.2 programmer.
javaw.exe was used to run applets*.
java.exe was used to run classes with a "main" method.
So easy. Any platform.

java.applet.Applet from the AWT GUI libraries.
Swing appears few years later...

Seravanthi said...

Yes, key difference between java and javaw is that java got console attached while javaw executeds Java program without console, that's why Java web start, applets they all use javaw.exe and print error in window if something failes e.g. when an appled failed to load. You can use java.exe to core Java program which starts from main method.

Vidhya said...

There is one more to the list javaws.exe or simply javaws which is used to launch Java application e.g. Swing GUI distributed using Java Web Start and JNLP. javaws jnlp_url is used to launch the application and then it downloads the version from server and stores it locally inside AppData folder of your user directory. Every time it runs it will check if an updated version is available or not, if not then it will run the appliation from local cache, while if a new version is present, it will first download the version and then executes.

Post a Comment