How to Install and Configure Java Development Kit(JDK) and Runtime Environment(JRE) for use with Command Prompt in Windows 10



Java is a very powerful programming language. You can do pretty much everything in Java. An IDE will be helpful but you don't always need an IDE to get started with Java. Instead, you can simply write text files with the .java extension and compile and run them manually. Setting such a simple development environment for Java is often a bit tricky for beginners. Because you don't just have to install the necessary files, but you have to also mess with some of the system environment variables. It might seem very difficult for a beginner, but it is actually pretty simple. 

From a beginner's perspective, Java Development Kit seems very confusing at first. But it is actually pretty straightforward once you understand it. 




In order to do this, you have to install 2 important files. One is Java Runtime Environment (JRE) which lets you execute java programs and java classes, and the other one is Java Development Kit (JDK) which lets you manually compile java programs from the command line. It is very easy and straightforward to install the Java Runtime Environment(JRE) but an installation alone won't be enough to get you started when it comes to Java Development Kit(JDK).

Java version names are also very confusing at first. So, in this article, we are focusing on how to install and configure the Java 8 SE version of both JDK and JRE.

So here is a step-by-step guide to installing and configuring JDK and JRE in your Windows 10 Machine.

  1. Download JDK 8 exe file for your system (x86 if 32bit or x64 if 64bit)

    Download JDK

  2. Download JRE 8 exe for your system (x86 if 32bit or x64 if 64bit)

    Download JRE

  3. Install JRE exe file first. Do not change the installation directory(because that can make it even more confusing if you are a beginner). Follow the instructions in the installation wizard and install it with everything default. 
    By default, it will be installed in C:\Program Files\Java
  4. Now install the JDK exe file. Just like before, follow the installation wizard and do a default installation. It should by default get installed to the same folder where JRE got installed(if you didn't change anything). 
    By default it will also be installed in C:\Program Files\Java
  5. Now, open the file explorer and navigate to the installation directory. ie. C:\Program Files\Java
    In this folder, you will see 2 folders with names similar to what you see in the image below:



  6. Now open the jdk1.8.0_291 folder 



    Then Copy the Address of this Folder by clicking on the Location being shown on the top address bar of the File Explorer. The copied address will look like this: 
    C:\Program Files\Java\jdk1.8.0_291

  7. Now, Go to Start → Search and Search for Control Panel and open it.




  8. After opening the Control Panel, In the search bar of the Control Panel, Search for the term Environment Variables


     








  9. Now from the search result, click on Edit the system environment variables (the one with that icon on the left)






  10. From the System Properties Window which just opened up, click on the Environment Variables Button



  11. In the window which just opened up, you will see two sections namely User variables for <your username> and System variables
    We have to click on New in the System Variables section
  12. In the dialog which just opened up, type JAVA_HOME as the Variable name and paste the address of the jdk folder you copied before in the Variable value field.




    Then press OK

  13. Now, on the system variables section, find a System variable called "Path"
    Click to select it and then press the Edit button
  14. In the window being opened up, Click on New and type the following as a new path

    %JAVA_HOME%\bin

  15. Press OK and close all the windows. 

    Now we have successfully completed the installation as well as configuring of JDK and JRE in Windows 10. 

    Open Command Prompt and type javac -version to see if the environment variables are successfully set up. If it shows a version, then it means everything was done correctly. 

Now that you set up a development environment, you can simply make a folder, make text files with a .java extension and compile and execute java programs directly from the command prompt. 

Use the following commands to enter the folder where you saved your java program files(.java files), compile the .java files and execute/run the compiled programs(.class files). 
  1. cd [FOLDER LOCATION ADDRESS]
  2. javac programfilename.java
  3. java programfilename
It is as simple as that. You don't need anything more than the Notepad and command prompt to write and test java programs from now on. An IDE(Integrated Development Environment may be preferred over this method when you are doing serious projects. But for learning purposes, this is the easiest and the simplest as well as the lightest method.

Happy Coding!

If you found this article helpful, please leave your thoughts on the comments, and follow me on Instagram @nived_kannada




Video: How to Set-Up Java JDK and JRE in Windows 10 with Environment Variables to Work on Command Prompt


This is a quick little tutorial on how to install and configure Java Development Kit and Java Runtime Environment in Windows 10 to easily compile and execute your java programs. This will help you get started with programming in Java the easiest way.

1 comment:

Post a Comment

Pages

Nanogalaxy is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for website owners to earn advertising fees by advertising and linking to amazon.com and any other website that may be affiliated with Amazon Service LLC Associates Program.