ShowTutorials.com

Refreshing your ideas and broadening your visions


Installing JDK

In order to start Java programming, we need some tools and environment. So, for developing java programs we require JDK (Java Development Kit). It consists for compiler, virtual machine and runtime environment which will help us to compile and execute the java programs.

For example, say we have a java program as Sample.java. We compile this using the command: javac Sample.java.
After running this command, JDK will create file Sample.class, which is the bytecode file
Sample.java -> (javac) -> Sample.class
Now we can execute the program in JRE using the command: java Sample

Installation

Following are the steps to install JDK on a Windows computer. Steps should be similar to other operating systems.

  1. Search in browser using any search engine for ‘Download JDK’ and go to the download site, or you can directly go to  Oracle site to download JDK
  2. After downloading the JDK installer and executing it, will start the Installation wizard. Just follow along and complete the installation.
  3. After installation, open the Command prompt and type java -version. It should show the java version. In case the command doesn’t work then we need to explicitly set the environment variables for java.

    Say the JDK installation directory is C:\Program Files\Java\jdk-17
    Then, open the System Properties -> Click Environment Variables.. Button and add the following entries:

    JAVA_HOME: C:\Program Files\Java\jdk-17
    PATH: C:\Program Files\Java\jdk-17\bin
    CLASSPATH: C:\Program Files\Java\jdk-17\lib

    Add environment variables

  4. Restart Command prompt and type java -version. It should work and show the java version. This completes the JDK installation and setup. Now the setup is ready to compile and execute java programs.

    java-command-prompt-version

Latest Topics: