Java JDK Installation

Some PCs might have Java already installed.

To check if you have Java installed on a Windows PC, search in the start bar for Java or type the following in Command Prompt (cmd.exe):

 C:\Users\Your Name>java -version 

Before you start

Java development environments have two basic approaches: to IDE or not to IDE.

IDE

You can use an integrated development environment (IDE) , such as IntelliJ IDEA, Netbeans or Eclipse, which are particularly useful when managing larger collections of Java files.

These tools combine a full-featured source editor.

Not to IDE

Or you can use just the basic command-line tools that are available free from Oracle’s Java website (http://java.oracle.com). Then you can use any text editor you want to create the text files that contain your Java programs. You can compile and run your programs by typing commands at a command prompt.

Downloading the JDK

To start writing Java programs, you have to download and install the correct version of the Java Development Kit (JDK).

Oracle’s Java website provides versions for Windows, Solaris, and Unix. If you prefer, you can download and install the open-source version of Java from http://openjdk.java.net.

To get to the download page, point your browser to www.oracle.com/java/technologies. Then follow the links to download the Java SE.

The JDK download comes in two versions: an executable installer and a .zip file.

JDK Installation

After downloading the JDK file, install it by running the executable file you downloaded.


Setup for Windows

To install Java on Windows:

  1. Go to “System Properties” (Can be found on Control Panel > System and Security > System > Advanced System Settings)
  2. Click on the “Environment variables” button under the “Advanced” tab
  3. Then, select the “Path” variable in System variables and click on the “Edit” button
  4. Click on the “New” button and add the path where Java is installed, followed by \bin. By default, Java is installed in C:\Program Files\Java\jdk-15.0.2 (If nothing else was specified when you installed it). In that case, You will have to add a new path with: C:\Program Files\Java\jdk-15.0.2\bin
    Then, click “OK”, and save the settings
  5. At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine

Step 1

Step 2

Step 3

Step 4


Java Quickstart

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

Let’s create our first Java file, called Main.java, which can be done in any text editor (like Notepad).

The file should contain a “Hello World” message, which is written with the following code:

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

Don’t worry if you don’t understand the code above – we will discuss it in detail in later chapters. For now, focus on how to run the code above.

Save the code in Notepad as “Main.java”. Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type “javac Main.java”:

C:\Users\Your Name>javac Main.java 

This will compile your code. 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 

The output should read:

Hello World 

Congratulations! You have written and executed your first Java program.

Also Read – Category Web Development


Check Out Deals on -> Amazon , Flipkart , Myntra , Adidas , Apple TV , Boat , Canva , Beardo , Coursera , Cleartrip , Fiverr , MamaEarth , Swiggy


That’s it!
You have successfully completed the post. Do Share : )

Peace Out!

2 Comments

Leave a Reply

Your email address will not be published.