Install JDK And Write A Simple “Hello World” Java Program, Compilation, Debugging, Executing Using Java Compiler And Interpreter

1

Install Jdk And Write A Simple “Hello World” Java Program, Compilation, Debugging, Executing Using Java Compiler And Interpreter

Install JDK And Write A Simple “hello World” Java Program, Compilation, Debugging, Executing Using Java Compiler And Interpreter

In this blog, we will understand that how to install JDK known as The Java™ Development Kit and run our first common program which is "Hello World".


Here are the steps to install JDK, write a "Hello World" program, compile it, and execute it using the Java compiler and interpreter:


Install JDK
  • Go to the Oracle website and navigate to the Java SE downloads page. (Click Here To Download)
  • Accept the license agreement, and then download the appropriate JDK package for your operating system (Windows, Mac, or Linux).
  • Once the download is complete, run the installer file.
  • Follow the prompts in the installer to select the installation directory, specify any optional components you want to install, and configure any advanced settings.
  • Wait for the installation to complete.
  • Once the installation is finished, you may need to set the JAVA_HOME environment variable to point to the installation directory. This will vary depending on your operating system.
  • Test the installation by opening a command prompt or terminal window and typing "java -version". If the installation was successful, this should display the version number of the JDK you just installed.

Write a "Hello World" Program
  • Open a text editor, such as Notepad or TextEdit.
  • Type the following code into the editor:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

  • Save the file as HelloWorld.java.


compile

  • Open a command prompt or terminal window.
  • Navigate to the directory where you saved HelloWorld.java.
  • Type the following command to compile the program:

javac HelloWorld.java

  • If there are no errors, a new file named HelloWorld.class will be created in the same directory.


Execution

  • Type the following command to execute the program:

java HelloWorld
  • If everything worked correctly, the following output should appear on your screen:
Hello World

That's it! You've now installed the JDK, written a "Hello World" program, compiled it, executed it, and even learned the basics of debugging.

❤️ I Hope This Helps You Understand, Click Here To Do More Exercise In Java Programming.


Post a Comment

1Comments
Post a Comment