Java Env Setup

Java Instalation

Some PCs might have Java already installed.

To check if you have Java installed on a Windows PC, type this following in Command Prompt (cmd.exe):

Cmd:
C:\Users\Your Name>java -version

If Java is installed in your system, you will see something like this (depending on version) in the Command Promt:

output of Cmd:
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Note:

You can write Java code in a text editor, but it's also convenient to use Integrated Development Environments like IntelliJ IDEA, NetBeans, or Eclipse, especially for larger Java projects.

Setup for Windows

To install Java on Windows:

  • Open "System Properties" (found in Control Panel > System and Security > System > Advanced System Settings).
  • Click "Environment Variables" under the "Advanced" tab.
  • In the "System variables" section, find and select the "Path" variable, then click "Edit."
  • Click "New" and add the path to your Java installation followed by "\bin." The default installation path is usually "C:\Program Files\Java\jdk-11.0.1" (unless you chose a different location during installation). In that case, add a new path like this: "C:\Program Files\Java\jdk-11.0.1\bin."
  • Click "OK" to save the changes.
  • Finally, open Command Prompt (cmd.exe) and type "java -version" to verify that Java is installed and working on your computer.

Java Quick Start

In Java, every application starts with a class name that must match the filename.

To create our first Java file named "Main.java," you can use a simple text editor like Notepad

In this file, write a "Hello World" message using the following code:

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

If the code isn't clear to you right now, that's okay; we'll explain it later. For now, let's focus on running it.

  • Save the code in Notepad as "Main.java."
  • Open Command Prompt (cmd.exe).
  • Go to the directory where you saved your "Main.java" file.
  • C:\Users\Your Name>javac Main.java

If there are no errors in the code, the command prompt will take you to the next line. Now, type "java Main" to run the file:

  • C:\Users\Your Name> java Main

Great job! You've successfully created and run your first Java program!

Contact Us

Name
Email
Mobile No:
subject:
Message: