Search anything:

Difference between java, javaw, javaws and javac

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

In this article at OpenGenus, we will learn about difference between java, javaw, javaws and javac in Java Programming Language.

Table of Contents

  1. Introduction
  2. Basic Differences betweeen java, javaw, javaws and javac.
  3. Java Compiler (javac)
  4. Java Virtual Machine (JVM)
  5. Java Application (java)
  6. Java Windowed Application (javaw)
  7. Java Web Start (javaws)
  8. Conclusion

Key Takeaways

  • Java, Javaw, Javaws, and Javac each serve distinct purposes.
  • Javac transforms Java source code into platform-independent bytecode.
  • The JVM interprets bytecode and executes Java applications.
  • Java directly executes Java applications.
  • Javaw is designed for windowed Java applications.
  • Javaws simplifies web application deployment for a seamless user experience.


Java, a versatile and widely-used programming language, comes with a range of tools and utilities that can sometimes perplex even the most seasoned developers. In the world of Java, terms like 'javac,' 'java,' 'javaw,' and 'javaws' may seem like a mysterious alphabet soup, but they play pivotal roles in the Java ecosystem.

In this article at OpenGenus, we will embark on a journey to demystify these Java components and unravel their distinct purposes. Whether you're a budding Java enthusiast or a seasoned developer looking to deepen your understanding, we'll provide you with a comprehensive guide to 'javac,' 'java,' 'javaw,' and 'javaws.'

We'll start by exploring the Java Compiler ('javac')—the tool that transforms human-readable Java source code into platform-independent bytecode. Then, we'll dive into the heart of Java execution—the Java Virtual Machine (JVM), which interprets bytecode and executes Java applications.

Next, we'll introduce you to the world of Java applications ('java') and Java Windowed Applications ('javaw'). These terms might sound similar, but they serve different purposes, and understanding their distinctions is crucial.

Finally, we'll unveil the wonders of Java Web Start ('javaws'), a technology that simplifies the deployment of web applications and ensures a seamless experience for end-users.

So, if you've ever been curious about these Java enigmas and want to grasp their significance, join us on this enlightening journey through the Java ecosystem. Let's decode 'javac,' 'java,' 'javaw,' and 'javaws' together.

Basic Differences betweeen java, javaw, javaws and javac

Below is a comprehensive comparison table that highlights the key differences and characteristics among four essential Java tools: javac, java, javaw, and javaws. These tools are integral to the Java ecosystem and serve distinct purposes, from compiling source code to running Java applications in various environments. This table offers insights into their applications, usage frequency, basic functioning, and other essential aspects, providing a quick reference for developers and enthusiasts interested in the Java platform.

Category javac java javaw javaws
Basic Working Compiles source code into bytecode files. Compiles Java source files into bytecode. Executes Java applications. Executes Java Web Start applications using locally cached files.
Purpose Translates Java source code to bytecode. Compiler for Java source code. Executes Java applications. Executes Java Web Start applications.
Execution java code java code javaw code javaws code.jnlp
Usage Compile Java source files. Compile Java source files. Execute GUI applications. Execute Java Web Start applications.
Applications Desktop, server, Android apps. Desktop, server, Android apps. Desktop applications. Java Web Start apps.
Performance Generally fast Generally fast Dynamic execution speed Dynamic execution speed
Safety Checks Yes Yes Yes Yes
Platform Independent Yes Yes Yes Yes

Java Compiler (javac)

At the heart of the Java development process lies the Java Compiler, denoted as 'javac.' This fundamental tool is responsible for translating human-readable Java source code into a lower-level representation known as bytecode. Here's a closer look at 'javac' and its pivotal role in the Java ecosystem:

  1. Compilation Process: The 'javac' command takes your Java source code files (usually with a .java extension) and compiles them. During compilation, 'javac' performs several essential tasks:

    1.1. Syntax Checking: It verifies that your code adheres to the syntax rules defined by the Java language. Any syntax errors are reported during this phase.

    1.2. Semantic Analysis: 'javac' goes beyond syntax and analyzes the semantics of your code, ensuring that it follows Java's type system and rules.

    3.3. Bytecode Generation: Upon successful compilation, 'javac' generates platform-independent bytecode files. These files have a .class extension and contain instructions that the Java Virtual Machine (JVM) can understand.

  2. Platform Independence: One of Java's key strengths is platform independence. 'javac' plays a vital role in achieving this by producing bytecode that can run on any platform with a compatible JVM.

  3. Debugging and Optimization: 'javac' allows developers to include debugging information in bytecode, aiding in the identification and resolution of issues. Additionally, it provides optimization options to enhance the performance of the compiled code.

  4. Executable Files: Unlike some programming languages that produce native executable files, Java relies on bytecode. This means that after compiling with 'javac,' you won't get a traditional .exe file but rather a .class file containing bytecode.

In summary, 'javac' is the first essential step in the Java development process. It takes your source code and transforms it into a platform-independent bytecode format, setting the stage for execution on the Java Virtual Machine (JVM).

In the next sections, we'll explore 'java,' 'javaw,' and 'javaws,' shedding light on how they interact with the bytecode produced by 'javac' and contribute to the diverse world of Java applications.

Java Virtual Machine (JVM)

The Java Virtual Machine, often abbreviated as JVM, is the cornerstone of the Java platform, enabling the execution of bytecode generated by the 'javac' compiler. It plays a pivotal role in making Java a "write once, run anywhere" language. In this section, we'll delve into the workings of the JVM and its significance in the Java ecosystem.

  • Runtime Environment: The JVM serves as a runtime environment for executing Java applications. It acts as an intermediary between your compiled Java bytecode and the underlying hardware and operating system.

  • Platform Independence: One of the JVM's most remarkable features is its ability to provide platform independence. It achieves this by interpreting and executing bytecode, making Java applications inherently cross-platform.

  • Execution of Bytecode: When you run a Java application, the JVM loads the corresponding bytecode (.class) files and executes them. This execution can take different forms, including interpretation and Just-In-Time (JIT) compilation.

  • Interpretation vs. JIT Compilation: The JVM can interpret bytecode line by line, executing it on-the-fly. Alternatively, it can use a Just-In-Time compiler to translate bytecode into native machine code for more efficient execution. This hybrid approach balances between startup speed and runtime performance.

  • Memory Management: The JVM manages memory allocation and garbage collection, relieving developers from manual memory management tasks. This enhances the robustness and reliability of Java applications.

  • Class Loading: The JVM employs a class-loading mechanism to load and link classes as needed during runtime. This dynamic loading allows Java applications to adapt and load classes on-demand.

  • Security and Sandbox: JVMs are equipped with security features to ensure that Java applications run safely. They employ a "sandbox" environment to restrict potentially harmful operations and protect the host system.

  • Variants and Implementations: While the term "JVM" is often used generically, there are multiple implementations available, such as Oracle HotSpot, OpenJ9, and GraalVM. These implementations may offer different performance characteristics and optimizations.

In essence, the Java Virtual Machine acts as the execution engine for Java applications. It bridges the gap between platform-independent bytecode and the specific hardware and operating system, making Java a versatile and widely adopted programming language. Understanding the JVM is essential for Java developers, as it enables them to create robust, portable, and secure applications.

Java Application (java)

The Java Compiler, invoked via the javac command, plays a pivotal role in Java development. It facilitates the transition from human-readable Java source code (.java) to platform-independent bytecode (.class) that can be executed on the Java Virtual Machine (JVM).

  • Compilation: javac takes Java source code files and compiles them into bytecode. During this process, it performs essential checks, including syntax validation and type checking.

  • Error Handling: One of its vital functions is to identify and report any compilation errors or warnings in the source code.

  • Bytecode Generation: The compiler generates .class files, containing bytecode instructions that the JVM can interpret and execute.

  • Platform Independence: Java's compilation process is a key factor in Java's "write once, run anywhere" capability, ensuring that bytecode is not tied to any specific platform.

  • Cross-Compilation: Developers can use javac to compile code for a different Java version or platform, offering versatility in project development.

  • IDE Integration: javac is integrated into popular Integrated Development Environments (IDEs) like Eclipse and IntelliJ IDEA, where it quietly handles the compilation process behind the scenes.

Comprehending how javac operates is fundamental for Java developers to create robust, cross-platform applications efficiently.

Java Windowed Application (javaw)

Introduction: Java Windowed Application (javaw) is a Java runtime command designed for running graphical applications with a user interface (UI). It was developed by Sun Microsystems (now Oracle Corporation). It ensures a streamlined experience by suppressing the console window.


  • javaw is used to execute Java applications that have graphical user interfaces (GUIs).
  • It's ideal for GUI-only applications where the console window is unnecessary.


  • To run a Java application with javaw, open your terminal/command prompt.
  • Navigate to the directory containing your compiled .class files.
  • Use the javaw command followed by the name of your class with the main method.


  • Suitable for GUI applications: javaw is tailored for GUI-based Java applications, ensuring a clean user experience without console distractions.
  • User-friendly: Provides a smoother execution environment for end-users by avoiding console windows.


  • Limited to GUI: javaw is intended for GUI applications and may not be suitable for applications that rely on console interactions or batch processing.

This code creates a basic Java GUI application that displays a window containing the text "Hello, World!" using Swing.

import javax.swing.*;

public class HelloWorldGUI {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("Hello, World GUI");
            JLabel label = new JLabel("Hello, World!");

            frame.setSize(300, 100);

You can execute it using javaw as follows:

javaw MyGuiApp

This will launch the GUI application without displaying a console window.When you compile and run this program, you'll see a small window with the message.

To compile and run the program:

  1. Save the code to a file named HelloWorldGUI.java.
  2. Open your terminal or command prompt.
  3. Navigate to the directory where you saved HelloWorldGUI.java.
  4. Compile the code with the command: javac HelloWorldGUI.java
  5. Run the program with the command: javaw HelloWorldGUI

This will launch the GUI application using javaw, and you'll see the "Hello, World!" message in a window.

This example is minimal and intended to demonstrate how javaw works to display a simple GUI window using Swing. You can modify and expand upon it for more complex GUI applications.

Java Web Start (javaws)

Certainly! Here's a brief overview of "Java Web Start (javaws)" along with a simple example to demonstrate how it works:

Java Web Start (javaws):

  • Introduction: Java Web Start, often abbreviated as javaws, is a technology developed by Sun Microsystems (now owned by Oracle) that allows you to launch full-featured Java applications directly from the web using a single click. It provides an efficient way to deploy and run Java applications on client machines without the need for manual installation.

  • Purpose: The primary purpose of javaws is to simplify the deployment and management of Java applications for end-users. It eliminates the need for users to download and install Java applications manually, making it easier to distribute and maintain Java-based software.

  • Usage: javaws is commonly used for launching Java applications that are hosted on web servers or accessible via URLs. Users can launch these applications by clicking on links or buttons on web pages.

  • Example: Let's create a simple Java application and use javaws to launch it from a web page.

Simple Java Web Start Example:

  1. Create a Java application with the following code and save it as HelloWebStart.java:
import javax.swing.*;

public class HelloWebStart {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JOptionPane.showMessageDialog(null, "Hello, Web Start!");
  1. Compile the Java application: javac HelloWebStart.java

  2. Create a JNLP (Java Network Launching Protocol) file named HelloWebStart.jnlp with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
        <title>HelloWebStart Example</title>
        <vendor>Your Vendor Name</vendor>
        <j2se version="1.8+" />
        <jar href="HelloWebStart.jar" main="true" />
    <application-desc main-class="HelloWebStart" />
  1. Create a JAR file containing your compiled Java application:
jar cvfe HelloWebStart.jar HelloWebStart *.class
  1. Host the JAR file and the JNLP file on a web server or a publicly accessible location.

  2. Now, you can use javaws to launch the Java Web Start application:

javaws http://your-website.com/path-to-HelloWebStart.jnlp

Replace http://your-website.com/path-to-HelloWebStart.jnlp with the actual URL where your JNLP file is hosted.

When you run this command, javaws will download and launch the Java Web Start application, displaying a dialog box with the message "Hello, Web Start!"

This example demonstrates how javaws can be used to launch Java applications directly from a web source, making it more convenient for end-users to access and run Java software.


In this comprehensive article, we delved into the distinctions between four crucial Java-related terms: "Java," "Java Virtual Machine (JVM)," "Java Compiler (javac)," and "Java Web Start (javaws)." We embarked on our journey by understanding the basics of Java as a versatile programming language renowned for its "write once, run anywhere" philosophy. Subsequently, we explored the JVM, which acts as the engine responsible for executing Java bytecode, making platform-independent execution possible.

Our discussion extended to the Java Compiler (javac), the tool responsible for translating human-readable Java source code into bytecode that the JVM can understand. We scrutinized the compilation process and its significance in bridging the gap between human-written code and machine-executable instructions.

Additionally, we demystified Java Web Start (javaws), a technology designed to simplify the deployment and management of Java applications via the web. Through a hands-on example, we showcased how javaws facilitates the effortless launching of Java applications directly from a web source, enhancing user accessibility and convenience.

In conclusion, this OpenGenus article offered a comprehensive understanding of these Java-related terms, shedding light on their roles and significance in the Java ecosystem. By exploring the compilation and execution phases, we unveiled the magic behind turning Java code into running software. Furthermore, our practical examples illustrated the practical applications of these concepts. Whether you're a budding Java developer or an enthusiast, this article equipped you with the knowledge needed to navigate the world of Java with confidence.

Manish Singh

Manish Singh is a student at Graphic Era Hill University.

Read More

Improved & Reviewed by:

Difference between java, javaw, javaws and javac
Share this