Saturday, January 8, 2022

Install Java

 Install Java 17 and Java Helloworld program 

Before starting with installation, let us check whether you have java installed in your machine already or not. 

Open command prompt and type javac in any path like below 

javac and java are executables only be available if java installed in the machine 

 

  

If this command says the “javac is not recognized as an internal or external command” which means either java is not installed or java is installed but java  executables are not configured to be identifiable from any path in your machine. 

Then let us start with installation 

  1. Open google search and search for java software download 

  1. In the search results, click on Java downloads link of oracle.com website 

 

 

It takes us to the below page 

 

 

 

Go to Windows section if you are installing on windows machine 

 

 

 

Select X64 installer for installing on Windows OS 64 bit verion 

Now the software will be downloaded 

 

 

Click on exe file and it will start the installation process 

 

 

 

 

 

 

 

 

Follow the instructions from the installation wizard and select the path where you want to install java 

 

 

Here if you want to the change the installation path, you can change it 

 

 

Installation started 

 

 

Installation completed 

 

 

 

If you now go to command prompt and type the same javac command, its shows details of the command. 

This is because java installation is completed and also the path of this javac command is also configured in system environment variables 

 

 

Let us check what is there in the environment variables 

Open search menu in your windows machine and search for “System Environment variables” 

Click on Environment Variables button 

 

Check for path entry in system variables section 

 

 

Select it and click on Edit you will find the path related to Java 

 

 

 

Go to that path in windows explorer. You can see java, javac exe files are copied and this path is configured in the path during installation. That is why you are able to see javac command result in command prompt immeditely after installation. 

 

 

 

 

Not only javac, java but here are many other executable files comes along with Java installation. In order to access all those executables, from any path of your machine in command prompt or from any other application, you have to set the java installation path to your path entry in system environment variables 

Let us do that now 

Go to java installation directory 

 

 

Copy the bin directory path of your installation, go to system environment variables and create a new entry in path. 

 

Reopen your command prompt and check for javac, java and javap 

Javac is used to compile the java program 

 

 

Java command is used to execute the java program 

 

 

Javap command is used to display the protected and public fields methods of the class passed to it. 

 

 

 

 

 

 You can also find the version java compiler and java command by the following commands 

javac –version 

java –version 

 

 

 

 

 

Finally, let us write a sample HelloWorld class and save the file with same name as that of class name.  

 

 

 

 

Go to that path in command prompt use javac and java commands to compile and execute 

 

 

 

 

 

 

That’s all for now. In my next post, I will explain what is behind and why we have to write main method like this as in our HelloWorld program. 

No comments:

Post a Comment

Difference between Procedure Oriented Programming System and Object Oriented Programming System (POPS vs OOPS)

POPS vs OOPS   Today we will get to know the difference between Procedure oriented Programming system (POPS) and  Object-Oriented  Programmi...