CodeToConcept
About

java

java Tutorials

Introduction
Java Fundamentals
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Control Statements
Java Class & Object
java Method
Java Constructor
Java this keyword
OOP Principles
Java super keyword
Coming Soon Topics

java Tutorials

Introduction
Java Fundamentals
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Control Statements
Java Class & Object
java Method
Java Constructor
Java this keyword
OOP Principles
Java super keyword
Coming Soon Topics

Sample Question

Think it through, then check the tutorial.

CodeToConcept

Quickly learn through simple, structured, and practical coding tutorials. Build your confidence from step zero to real-world experience.

Β© 2026 CodeToConcept. All rights reserved.

Quick Links

AboutTutorials

Tutorials

Java

Support

Privacy PolicyTerms of ServiceContact
GitHubTwitterYouTube

Compilation And Execution

  1. Open notepad or any text editor and write the below code and save it as HelloWorld (with dot java extension).

Example : HelloWorld.java


public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Note : The file name should be same as the class name and should have .java extension.


  1. Now open Command Prompt and navigate to the directory where you saved the HelloWorld.java file using the cd command. For example, if you saved it in the Documents folder, you can use the following command:

cd C:\Users\ashis\OneDrive\Documents

Example :

Command Prompt
  1. Now to compile the Java program, use the following command:

javac HelloWorld.java

This command will compile the HelloWorld.java file and generate a HelloWorld.class file in the same directory. The .class file contains the bytecode which can be run/executed by the Java Virtual Machine (JVM). Example :

Command Prompt
  1. Now to execute the compiled Java program, use the following command:

java HelloWorld

This command will run the HelloWorld.class file using the Java Virtual Machine (JVM). You will see the output Hello, World! in the Command Prompt.

Example :

Command Prompt

Great! You have successfully compiled and executed your first Java program πŸ™‚.

See you in next page....πŸ™‚

← Java InstallationJava First Program β†’
← Java InstallationJava First Program β†’