How to install Java JDK and JRE in Linux and Windows (with details)

[En Español: clic aquí]

The JDK has a collection of progamming tools, including java, javac, javadoc, javaws, jar, apt, appletviewer, visualVM, etc. Too, the JDK also comes with a complete Java Runtime Environment, usually called a private runtime, due to the fact that it is separated from the “regular” JRE and has extra contents. It consists of a Java Virtual Machine and all of the class libraries present in the production environment, as well as additional libraries only useful to developers, such as the internationalization libraries and the IDL libraries (wikipedia reference).

So, the JDK is necessary for several things that I have proposed in this blog during some years, so that I have decided include an article more complete about it. There are others JDKs (different to Java JDK): for example OpenJDK. Here, I am going to write only about Java JDK.

  1. How to install Java JDK and JRE in Windows:
    1. Check if you have Java JDK 1.7 or higger in Windows.
    2. Check your “Environment Variables”.
  2. How to install Java JDK and JRE in Linux:
    1. Check if you have Java JDK 1.7 or higger in Linux.
    2. Other posibilities.

1. How to install Java JDK and JRE in Windows.

1.1. Check if you have Java JDK 1.7 or higger in Windows.

Go to “Computer” and access to “C:\Program Files\Java”, and check the folder that you have.

Folder Java

In my case, I have 2 versions of JDK (1.6 and 1.7) and 2 versions of JRE (jre6 and jre7). What is your case?

a) JDK: Do you have a folder called “jdk1.7…” (or higger)?

  • If it is so, go to the step b).
  • If you have not that folder:
    • 1. Download the Java JDK 7 since here. Accept the License Agreement if you agree, and download your Windows version.
      • Note: If you don’t know what is your version (32 or 64 bits), go to your desktop and click with the right bottom on “Computer”. You will see in the new window a line where is wrote: “System type: XX-bit Operating System”. Download the version x86 for 32 bits and the version x64 for 64 bits.

Java JDK 7 Download

    • 2. Install the Java JDK 7 that you have downloaded. It is very simple: Next, Next, Next… Finish.

b) JRE: Do you have a folder called “jre7…” (or higger)?

  • If it is so, go to the step 1.2.
  • If you have not that folder:
    • 1. Download the Java JRE 7 since here. Accept the License Agreement if you agree, and download your Windows version (the exe option is easier for install).
      • Note: If you don’t know what is your version (32 or 64 bits), go to your desktop and click with the right bottom on “Computer”. You will see in the new window a line where is wrote: “System type: XX-bit Operating System”. Download the version x86 for 32 bits and the version x64 for 64 bits.
    • 2. Install the Java JRE 7 that you have downloaded. It is very simple: Next, Next, Next… Finish (yes, it is pretty similar to the step a) xD ).

1.2. Check your “Environment Variables”.

The form easiest is:

  • Go to Start / and write in the search textbox “cmd”.
  • Click in “cmd.exe”. This is the command environment of Windows.
  • Write here: java -version

cmd java version

  • Posibilities:
    • If you have the version 1.7 or higger, you have not problem, you don’t need change your system… bye! (it is the case of the image).
    • If your have a smaller version, you need update your environment variables.
    • If you receive the text: “‘java -version’ is not recognized as an internal or external command…”, you need add a new environment variable.

If you need update or add an environment variable:

  • Go to your Desktop and click with the right bottom on “Computer”, and click on “Properties”.
  • In the new window, click in “Advanced system settings” (left side).
  • In the new window, click in “Advanced” (top side) and in the bottom “Environment Variables”.

System Properties and Environment Variables

  • In the new window, in the side of “System variables” add a new variable:
    • Check if the variable JAVA_HOME exist (and if exist, it is easier delete it and create a new one).
    • Click on “New”.
    • Variable name: JAVA_HOME
    • Variable value: C:\Program Files\Java\jdk1.7.XXX (insert your correct version)
    • Click on “OK”.
  • In the same window and in the same side (“System variables”), edit the variable “Path”:
    • Select the line where the variable is “Path”.
    • Click on “Edit”.
    • In the “Variable value”, access to the top right of the line and add: ;%JAVA_HOME%;%JAVA_HOME%\bin
      • The semicolon (;) is for separate the variables, and here is add the variable with the path and the variable with the bin path.
    • Click in “OK”.
  • Close the windows (click in OK).
  • In order to check if you have the correct version, open a new cmd.exe and write again the command: java -version

2. How to install Java JDK and JRE in Linux.

2.1. Check if you have Java JDK 1.7 or higger in Linux.

The steps are:

  • Open a terminal / shell.
  • Write the command: java -version

java version en ubuntu

  • Posibilities:
    • If you have the version 1.7 or higger, you have not problem, you don’t need change your system… bye!
    • If your have a smaller version, you need update your java version.
    • If you receive the text: “java -version: command not found”, you need add java in your system.
  • For both add and update java in the system, I recommend these simple steps:
    • Add this repository, command: sudo add-apt-repository ppa:webupd8team/java
    • Update all the respotories, command: sudo apt-get update
    • Install Oracle Java 8 and JDK 7, commands:
      • sudo apt-get install oracle-jdk7-installer
      • sudo apt-get install oracle-java8-installer
    • Check the version that the system is using, command: java -version
    • Posibilities:
      • If your version is 1.7 or higger, it is OK, everything is right (you have finished :) ).
      • If your version is smaller, we need change the versión that is running. For do it:
        • Either update the alternatives, command: sudo update-alternatives –config java
        • Or set up the Java 8 environment variables directly, command: sudo apt-get install oracle-java8-set-default

– 

2.2. Other posibilities.

  • If it is not running and you prefer uninstall it, command: sudo apt-get remove oracle-java8-installer
  • For delete the repositories:
    • Install the ppa-purge, command: sudo apt-get install ppa-purge
    • Delete the respository, command: sudo ppa-purge ppa:webupd8team/java

 

Leave a comment

Por favor, inicia sesión con uno de estos métodos para publicar tu comentario:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s