Environment Setup for Java

To work with Java, we have to setup java environment first. Follow below steps to start working with it:

Step1: Download and install the latest version of JDK (java development kit) with JRE (java runtime environment) (32 bit or 64 bit ) depending upon your operating system.

Download Link

a) Select JDK download from the below options (it includes JRE).

download JDK

b) Accept the license Agreement and Select the JDK version depending upon your Operating System. Download the JDK.

liecense accept

c) Install JDK by clicking next multiple times.

Step2: Create environment variable by name “JAVA_HOME” and set this variable value to JDK installation location.

Step 3: Update “path” environment variable to the bin folder of JDK location.

Step 4: Download latest version of eclipse IDE for j2ee developers (32 or 64 bits depending upon your Operating System).

Download Link

Step 5: Follow below steps to create a Java Project in Eclipse IDE:

a) File –> New –> Java Project. This will create a new project.

b) Enter Project name.

c) Keeping other configurations as default, Click Finish.

newProject

d) Right click src –> New –> Package –> <name of package> say package1. This will create a new package.

Note: By convention, package name always starts with a small letter.

You can also refer to below video for the same:

Now we are ready to start working with Java. Let us create a Java class which will have a main method.

Right click on package1 –> Class –> <name of the class>.

Note: By convention, the class name always starts with a capital letter.

Write below code in this class.

package package1;

public class HelloWorld {

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

	}

}

To execute the code Right Click –> Run as –> Java Application.

Note: Shortcut to write “System.out.println(“Hello World”);” –> type syso and press (CTRL + spacebar).

Shortcut to write “public static void main(String[] args)” –> type main and press (CTRL + spacebar).

For any questions, queries or comments. Feel free to write us at saurabh@qatechhub.com or support@qatechhub.com 🙂

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: