Let’s execute our first java program!

Gurram Harshavardhan Netha
3 min readJun 5, 2021

--

Okay, I know many may not believe this but, we need to accept the truth that we are into our 3rd year of engineering now. (Smile in pain!)

Well, OOPS is new course for all of us, where we implement things in .java

Now, let’s see how to install JAVA on our systems.

Step 1 — Install JAVA

Installation of JDK. From this link, download the JDK file ~150 MB and install it.

Productivity tip: x64 file is for 64 bit windows and x86 is for 32 bit version of windows. Make sure you download the correct package.

Step 2 — Setting up environment variables

Search for “Environment Variables” from start menu.

Find the path of JAVA on your system, most often that will be in below address

C:\Program Files\Java\jdk1.8.0_XXX

Setting up PATH: Now edit path variable(if exists) or create a new variable and name it as PATH and add the below directory to it.

C:\Program Files\Java\jdk1.8.0_XXX\bin

Setting up JAVA_HOME: Create a new variable and name it JAVA_HOME and add the below value to it.

C:\Program Files\Java\jdk1.8.0_XXX
In my case, I already have JAVA_HOME set. So it is shown in the list.

Step 3 — Write the code

Open any of your favorite text editor with and write the below lines into it and save it as: FirstJavaProgram.java

Note: public class defined in line 1 must be same as file name you save.

Step 4 — Execute!

Open command prompt in the folder where java file is located and execute below two commands:

javac FirstJavaProgram.java

// This command compiles the code

java FirstJavaProgram

// This command executes the code

Step 5 — Experiment!

And it’s in your hands how you do it. xD

References

--

--