Learn more about Java and Its installation

As in previous post we discuss about the introduction of Java now let’s do how can we use Java or how can we write it on practice it using an IDE (Integrated Development Environment) Now first we see how to install it ok.

java

How to Install Java

Some Computers or PC’s might have Java already installed. Whether we can also check that is there of any version already insatll in our PC or not.

How to check Version of Java Using (CMD)

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

NOTE : If the Java is already installed on your PC, you will see something like this (depending on version):

java 11.0.18 2023-01-17 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.18+9-LTS-195)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.18+9-LTS-195, mixed mode)

If Java’s Not installed What to Do?

If you do not have Java installed on your computer, you can download it for free at oracle.com.

Note: In this Article or you can say Blog, we will write Java code in a text editor. However, it is possible to write Java in an Integrated Development Environment, such as IntelliJ IDEA, Netbeans or Eclipse, which are particularly useful when managing larger collections of Java files.

java

Now Setup Java’s on Windows

To install Java on Windows you have to do various steps which are given under below:

Step 1: Go to “System Properties” (Can be found on Control Panel > System and Security > System > Advanced System Settings)
Step 2: Click on the “Environment variables” button under the “Advanced” tab
Step 3: Then, select the “Path” variable in System variables and click on the “Edit” button
Step 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-11.0.1 (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-11.0.1\bin
Then, click “OK“, and save the settings
Step 5: At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine

See how to Download Java With the help of images

Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Start writing JAVA

Now let’s start writing Java Code

Keep in mind; 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:

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

Output

Hello World!!!

Don’t worry if you don’t understand the code above – we will discuss it in detail it later. For now, focus on how to run or execute our written 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 that you have wriitne in your file. 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\<em>Your Name</em>&gt;java Main

The output of your code is:

Hello World!!!

Congratulations! You have written and executed your first Java code or you can say program.

Link: https://Codelikechamp.com

Medium Link: Follow me on Medium

Linkedin Link: Follow me on Linkedin

🤞 Don’t miss any latest posts!

Please subscribe by joining our community for free and stay updated!!!

IF YOU HAVE ALREADY SUBSCRIBED JUST CLOSE THIS FORM !

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top