What is Java?

Java is a high-level, object-oriented programming language.
It was developed by Sun Microsystems (now owned by Oracle Corporation) in the mid-1990s.
Java is known for its platform independence.
Java programs can run on various operating systems without modification.
It is widely used in web development, mobile app development (Android), and server-side applications.

History and Evolution

Java's history dates back to 1991 when it was initially called "Oak.”
In 1995, Sun Microsystems released Java as a programming language for the internet.
Java gained immense popularity due to its "Write Once, Run Anywhere” (WORA) capability.
Over the years, Java has gone through several versions and updates, introducing new features and improvements.

Installing JDK (Java Development Kit)

To start programming in Java, you need to set up the Java Development Kit (JDK) on your computer. Here are the basic steps for installing the JDK:
Visit the official Oracle website () or the OpenJDK website () to download the latest version of the JDK.
Choose the appropriate JDK version for your operating system (Windows, macOS, or Linux) and download the installer.
image.png
After installation,
set the JAVA_HOME environment variable to point to the JDK installation directory.
Set Environmental Variables in Java

Step 1: Add Java to System Variables

1. Open the Start menu and search for environment variables.
2. Select the Edit the system environment variables result.
Find the Edit system environment variables option.
3. In the System Properties window, under the Advanced tab, click Environment Variables…
Locating the Environment variables option under System properties in Windows.
4. Under the System variables category, select the Path variable and click Edit:
Editing the Path variable in Windows.
5. Click the New button and enter the path to the Java bin directory:
Adding a new Java variable in Windows.
Note: The default path is usually C:\Program Files\Java\jdk-17.0.1\bin.
6. Click OK to save the changes and exit the variable editing window.

Step 2: Add JAVA_HOME Variable

Some applications require the JAVA_HOME variable. Follow the steps below to create the variable:
1. In the Environment Variables window, under the System variables category, click the New… button to create a new variable.
Create a new JAVA_HOME variable in Windows.
2. Name the variable as JAVA_HOME.
3. In the variable value field, paste the path to your Java jdk directory and click OK.
image.png
4. Confirm the changes by clicking OK in the Environment Variables and System properties windows.

Test the Java Installation

Run the java -version command in the command prompt to make sure Java installed correctly:
Verify the installation by opening a command prompt (or terminal) and running the command java -version. This should display the installed Java version.
Running the java command to see Java version on Windows.
If installed correctly, the command outputs the Java version. Make sure everything works by writing a simple program and compiling it. Follow the steps below:

Step 1: Write a Test Java Script

Hello World Program

Let's create a simple "Hello World" program in Java to get started:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

In this program:
public class HelloWorld defines a class named HelloWorld.
public static void main(String[] args) is the main method, which serves as the entry point for our program.
System.out.println("Hello, World!"); prints the text "Hello, World!" to the console.
To run this program, compile it using the javac command and then execute it using the java command.

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.