31. Configure Java

Pre-requisite You have to install Java JDK as explained in my previous Post#30 Install Java JDK

Configuring the Java JDK:

Follow the below steps to configure the Java JDK:

We have to configure the Java by configuring the build path.

If you want to save the created java files outside the bin folder then you have to set path of JDK. Path is required for using Javac and Java tools. Javac tool compiles the Java code and Java tool will run the code.

How to set path of JDK will be explained below:

1. Click on 'My Computer' icon on your desktop as shown below - 

2. When your drives are displayed in your My Computer window, right click any where inside the window and select 'Properties' option as shown below -

3. Click on 'Advanced System Settings' option as shown below:

4. Click on 'Environment Variables Button as shown below:

5. Click on 'New' button under the User variables as shown below:

6. Type 'path' into the 'Variable Name' as shown below:

7.  In 32 bit machines -> Go to C:\Program Files (x86)\Java\jdk[Version]\bin folder and copy the path of the bin folder as shown below (But in 64 bit machines -> You need to go to C:\Program Files\Java\jdk[Version]\bin folder )

8. Paste path of the bin folder in Variable Value field as shown below and click on 'OK' button

9. Ensure that the path is added under the User variables and Click on 'OK' button as shown below to finish the process

Check whether the Installed and configured Java works:

1. Open Windows Command line as shown below:

2. Type the command java -version in the Command line window as shown below and press 'Enter' key on your keyboard as shown below:

3. Ensure that the Java version we've installed and configured is displayed on executing the command specified in step 2 as shown below:

If you see the version of Java that is installed as shown in the above screenshot, it means that your Java is working.

Now you are ready to run any java program. But before running the Java program lets go through a sample Java program and understand the basic concepts. 

Notes - 

1. You can also install JRE (Java Run Time Environment) instead of JDK (Java Development Kit). You can use Eclipse IDE and develop automation scripts when you install JRE instead of JDK prior to installing Eclipse IDE as Eclipse IDE contains its own features for developing and compiling Java.

2. If you want to Run Java Programs using any other editors instead of Eclipse IDE, then installation of Java JDK is must as the editors wont have  features to develop and compile Java programs. So installing JRE prior to running Java programs on any other editors instead of Eclipse IDE wont work. JDK is must in this case.

3. When you are running your automation scripts developed using Java programming language on Eclipse IDE, you can simply install JRE instead of JDK if you want to save your computers memory. JRE installation take less time and less memory to store.

Please comment below to feedback or ask questions.

A Sample Java program will be explained in the next Post.


Utkarsh Pawar said...

I am getting this error : The system cannot find the file.
I tried multiple times. I am using 64 bit OS. My Java folder is inside Program Files(x86)


Unknown said...

Hi Utkarsh,

If it is 64 bit OS, You can find Java folder in My computer-->Program files-->Java ( Not in Program Files(x86).

Sonu said...

Hi Arun,

Why you delete most of the post from java for selenium section as i am start learning but i find this after go through post one by one .

Arun Motoori said...

Looks like a technical issue. Resolved it.
Please check now.