Skip to content

Instantly share code, notes, and snippets.

@starlinq
Last active January 27, 2024 19:11
Show Gist options
  • Select an option

  • Save starlinq/9ee5209ceb32b7e05817e714fe530be3 to your computer and use it in GitHub Desktop.

Select an option

Save starlinq/9ee5209ceb32b7e05817e714fe530be3 to your computer and use it in GitHub Desktop.

Revisions

  1. starlinq revised this gist Jul 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -127,7 +127,7 @@ Paths can be different based on version and update, here the version is 1.8 and
    # PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_181/bin:/usr/lib/jvm/jdk1.8.0_181/db/bin:/usr/lib/jvm/jdk1.8.0_181/jre/bin"
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_181"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_181/jre*
    J2REDIR="/usr/lib/jvm/jdk1.8.0_181/jre*"
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_181"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_181/db"
    ```
  2. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -104,7 +104,7 @@ sudo update-alternatives --config javac
    sudo update-alternatives --config javaws
    ```

    7. Set environment variables
    8. Set environment variables

    Edit the environment file:

    @@ -117,7 +117,6 @@ My current environment file contains:
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    ```


    Update the existing PATH variable by adding the below bin folders, separated with a colon :.

    `/usr/lib/jvm/jdk1.8.0_181/bin:/usr/lib/jvm/jdk1.8.0_181/db/bin:/usr/lib/jvm/jdk1.8.0_181/jre/bin`
  3. starlinq revised this gist Jul 18, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -60,6 +60,8 @@ sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk1.8.0_version” will be moved to `/usr/lib/jvm`.

    Delete the .tar.gz file if you want to save disk space.

    6. Inform Ubuntu to use this JDK

    ```console
  4. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -131,13 +131,8 @@ JAVA_HOME="/usr/lib/jvm/jdk1.8.0_181"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_181/db"
    ```

    Save changes and close the file.
    Save changes and close the file. Log out and log in again.

    Reload it:

    ```console
    source /etc/environment
    ```
    You can now test whether the environment variable has been set by executing the following command:

    ```console
  5. starlinq revised this gist Jul 18, 2018. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,21 @@

    # How to install Java JDK8 in Ubuntu 16.04

    ## Installing the default JDK
    Let's consider a JDK8 installation using 2 different versions: default and Oracle. The default version is easiest because it is packaged with Ubuntu.

    There is default Java installation called the JDK (Java Development Kit). The JDK is usually only needed if you are going to to do some software developmwent using Java or if some software requires it. The JDK does contain the JRE.

    There is default Java installation called the JDK (Java Development Kit). The JDK is usually only needed if you are going to to do some software developmwent using Java or if some software requires it.

    The easiest option for installing Java JDK8 is using the version packaged with Ubuntu. This will install OpenJDK 8, the latest and recommended version.
    ## Installing the default JDK

    This will install OpenJDK 8, the latest and recommended version.

    First, update the package index:

    ```console
    sudo apt update
    ```

    The JDK does contain the JRE.

    You can install the JDK with the following command:

    ```console
  6. starlinq revised this gist Jul 18, 2018. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,27 @@

    # How to install Java JDK8 in Ubuntu 16.04

    ## Installing the default JDK

    There is default Java installation called the JDK (Java Development Kit). The JDK is usually only needed if you are going to to do some software developmwent using Java or if some software requires it.

    The easiest option for installing Java JDK8 is using the version packaged with Ubuntu. This will install OpenJDK 8, the latest and recommended version.

    First, update the package index:

    ```console
    sudo apt update
    ```

    The JDK does contain the JRE.

    You can install the JDK with the following command:

    ```console
    sudo apt-get install default-jdk
    ```

    ## Installing the Oracle JDK

    1. Download the latest JDK file

  7. starlinq revised this gist Jul 18, 2018. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -96,7 +96,7 @@ Update the existing PATH variable by adding the below bin folders, separated wit

    `/usr/lib/jvm/jdk1.8.0_181/bin:/usr/lib/jvm/jdk1.8.0_181/db/bin:/usr/lib/jvm/jdk1.8.0_181/jre/bin`

    HOME directory paths can be different based on version and update, here the version is 1.8 and the update is 181. Add the below variables at the end of environment file, making changes for your specific version and update.
    Paths can be different based on version and update, here the version is 1.8 and the update is 181. Add the below variables at the end of environment file, making changes for your specific version and update. I commented out original line.

    ```console
    # PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    @@ -114,6 +114,11 @@ Reload it:
    ```console
    source /etc/environment
    ```
    You can now test whether the environment variable has been set by executing the following command:

    ```console
    echo $JAVA_HOME
    ```

    Verify the Java version

  8. starlinq revised this gist Jul 18, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -109,7 +109,11 @@ DERBY_HOME="/usr/lib/jvm/jdk1.8.0_181/db"

    Save changes and close the file.

    Reload it:

    ```console
    source /etc/environment
    ```

    Verify the Java version

  9. starlinq revised this gist Jul 18, 2018. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -94,15 +94,19 @@ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u

    Update the existing PATH variable by adding the below bin folders, separated with a colon :.

    /usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin
    `/usr/lib/jvm/jdk1.8.0_181/bin:/usr/lib/jvm/jdk1.8.0_181/db/bin:/usr/lib/jvm/jdk1.8.0_181/jre/bin`

    HOME directory paths can be different based on version and update,here the version is 1.8 and the update is 151. Add the below variables at the end of environment file, making changes for your specific version and update.
    HOME directory paths can be different based on version and update, here the version is 1.8 and the update is 181. Add the below variables at the end of environment file, making changes for your specific version and update.

    ```console
    # PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_181/bin:/usr/lib/jvm/jdk1.8.0_181/db/bin:/usr/lib/jvm/jdk1.8.0_181/jre/bin"
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_181"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_181/jre*
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_181"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_181/db"
    ```

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin"
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre*
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
    Save changes and close the file.


  10. starlinq revised this gist Jul 18, 2018. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -83,19 +83,20 @@ sudo update-alternatives --config javaws
    Edit the environment file:

    ```console
    gedit /etc/environment
    sudo gedit /etc/environment
    ```
    My current environment file contains:

    ```console
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    ```


    Update the existing PATH variable by adding the below bin folders, separated with a colon :.

    /usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin
    HOME directory paths can be different based on version and update,here the version is 1.8 and the update is 151. Add the below variables at the end of environment file, making changes for your specific version and update.

    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre"
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
    The environment file should now be similar to this text:
    HOME directory paths can be different based on version and update,here the version is 1.8 and the update is 151. Add the below variables at the end of environment file, making changes for your specific version and update.

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin"
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
  11. starlinq revised this gist Jul 18, 2018. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -80,9 +80,12 @@ sudo update-alternatives --config javaws

    7. Set environment variables

    Edit the environment file.
    Edit the environment file:

    ```console
    gedit /etc/environment
    ```

    # vi /etc/environment
    Update the existing PATH variable by adding the below bin folders, separated with a colon :.

    /usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin
  12. starlinq revised this gist Jul 18, 2018. 1 changed file with 13 additions and 16 deletions.
    29 changes: 13 additions & 16 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -69,6 +69,8 @@ Press <enter> to keep the current choice[*], or type selection number:

    ```

    In this case, I select the last number and press enter to exit this utility i.e. in this example it is the number 2.

    If you are going to use `javac` and `javaws`, repeat the above for:

    ```console
    @@ -99,27 +101,22 @@ JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
    Save changes and close the file.

    Step 4: Inform Ubuntu about the installed location
    Use update-alternatives to inform Ubuntu about the installed java paths.

    # sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_151/bin/java" 0
    # sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_151/bin/javac" 0
    # sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_151/bin/java
    # sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_151/bin/javac
    Step 5: Setup verification
    Give the location of java and javac as you provided.

    # update-alternatives --list java
    # update-alternatives --list javac
    Restart the computer or open a new terminal.
    Verify the Java version

    ```console
    java -version
    ```

    Step 6: Verify the Java version
    # java -version
    The output should resemble the following:

    java version "1.8.0_151"
    Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
    ```console
    java version "1.8.0_181"
    Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
    ```

    You should be able to see your installed java version which means you have successfully installed the Oracle JDK.


  13. starlinq revised this gist Jul 18, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -69,6 +69,13 @@ Press <enter> to keep the current choice[*], or type selection number:

    ```

    If you are going to use `javac` and `javaws`, repeat the above for:

    ```console
    sudo update-alternatives --config javac
    sudo update-alternatives --config javaws
    ```

    7. Set environment variables

    Edit the environment file.
  14. starlinq revised this gist Jul 18, 2018. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,27 @@ This will assign Oracle JDK a priority of 1, which means that installing other J

    The executables `java, javac, javaws` are probably the most frequently used.

    7. If you have multiple java installations you need to configure it by

    ```console
    sudo update-alternatives --config java
    ```

    in my case (before this installation, I have installed OpenJDK8), it gives

    ```console
    There are 2 choices for the alternative java (providing /usr/bin/java).

    Selection Path Priority Status
    ------------------------------------------------------------
    * 0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 auto mode
    1 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
    2 /usr/lib/jvm/jdk1.8.0_181/bin/java 1 manual mode

    Press <enter> to keep the current choice[*], or type selection number:

    ```

    7. Set environment variables

    Edit the environment file.
  15. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1

    This will assign Oracle JDK a priority of 1, which means that installing other JDKs may replace it as the default. Use a higher priority if you want Oracle JDK to remain the default.

    The exetables `java, javac, javaws` are probably the most frequently used.
    The executables `java, javac, javaws` are probably the most frequently used.

    7. Set environment variables

  16. starlinq revised this gist Jul 18, 2018. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    1. Download the latest JDK file

    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, if there is no such page you can go to general download page <http://www.oracle.com/technetwork/java/javase/downloads/index.html>
    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, if there is no such page you can find it from general download page <http://www.oracle.com/technetwork/java/javase/downloads/index.html>

    The latest version is Java SE Development Kit 8u181.

    @@ -36,7 +36,19 @@ sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk1.8.0_version” will be moved to `/usr/lib/jvm`.

    6. Set environment variables
    6. Inform Ubuntu to use this JDK

    ```console
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_181/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_181/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_181/bin/javaws" 1
    ```

    This will assign Oracle JDK a priority of 1, which means that installing other JDKs may replace it as the default. Use a higher priority if you want Oracle JDK to remain the default.

    The exetables `java, javac, javaws` are probably the most frequently used.

    7. Set environment variables

    Edit the environment file.

  17. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -36,8 +36,8 @@ sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk1.8.0_version” will be moved to `/usr/lib/jvm`.

    6. Set environment variables

    Step 3: Set environment variables
    Edit the environment file.

    # vi /etc/environment
  18. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    1. Download the latest JDK file

    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, if there is no such page you can go to general download page <http://www.oracle.com/technetwork/java/javase/downloads/index.html>

    The latest version is Java SE Development Kit 8u181.

  19. starlinq revised this gist Jul 18, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    The latest version is Java SE Development Kit 8u181
    The latest version is Java SE Development Kit 8u181.

    The archive file for Linux x64 is `jdk-8u181-linux-x64.tar.gz`

    @@ -34,7 +34,7 @@ You will find a folder with the name as `jdk1.8.0_181`.
    ```console
    sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk_1.8_version” will be moved to `/usr/lib/jvm`.
    The complete folder “jdk1.8.0_version” will be moved to `/usr/lib/jvm`.


    Step 3: Set environment variables
  20. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-d

    The latest version is Java SE Development Kit 8u181

    The archive file for Linux x64 is jdk-8u181-linux-x64.tar.gz
    The archive file for Linux x64 is `jdk-8u181-linux-x64.tar.gz`

    Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

  21. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ You will find a folder with the name as `jdk1.8.0_181`.
    ```console
    sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk_1.8_version” will be moved to /usr/lib/jvm.
    The complete folder “jdk_1.8_version” will be moved to `/usr/lib/jvm`.


    Step 3: Set environment variables
  22. starlinq revised this gist Jul 18, 2018. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -32,18 +32,11 @@ You will find a folder with the name as `jdk1.8.0_181`.
    5. Let's move the directory to default system directory

    ```console
    sudo mv /jdk1.8.0_181 /usr/lib/jvm
    sudo mv ./jdk1.8.0_181 /usr/lib/jvm
    ```
    The complete folder “jdk_1.8_version” will be moved to /usr/lib/jvm.

    Create a jvm folder in /usr/lib/ which is the default location for Java.

    # sudo mkdir /usr/lib/jvm
    Go to the created /usr/lib/jvm folder.

    # cd /usr/lib/jvm
    Extract the downloaded JDK.

    # sudo tar -xvzf ~/Downloads/jdk-8u151-linux-x64.tar.gz
    Step 3: Set environment variables
    Edit the environment file.

  23. starlinq revised this gist Jul 18, 2018. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -25,9 +25,15 @@ $ cd ~/Downloads
    $ tar zxvf jdk-8u181-linux-x64.tar.gz
    ```

    You will find a folder with the name similar to “jdk_1.8u181”.
    The Java Development Kit files are installed in a directory called jdk1.8.0_version in the current directory.

    You will find a folder with the name as `jdk1.8.0_181`.

    5. Let's move the directory to default system directory

    ```console
    sudo mv /jdk1.8.0_181 /usr/lib/jvm
    ```

    Create a jvm folder in /usr/lib/ which is the default location for Java.

  24. starlinq revised this gist Jul 18, 2018. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,15 @@ If you download it from web browser, in typical configuration the file will be s
    ```console
    $ cd ~/Downloads
    ```
    4. Unpack the tarball

    ```console
    $ tar zxvf jdk-8u181-linux-x64.tar.gz
    ```

    You will find a folder with the name similar to “jdk_1.8u181”.


    Extract JDK to Java's default location

    Create a jvm folder in /usr/lib/ which is the default location for Java.

  25. starlinq revised this gist Jul 18, 2018. 1 changed file with 14 additions and 3 deletions.
    17 changes: 14 additions & 3 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,26 @@

    1. Download the latest JDK

    1. Download the latest JDK file

    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    The latest version is Java SE Development Kit 8u181

    The archive file is jdk-8u181-linux-x64.tar.gz
    The archive file for Linux x64 is jdk-8u181-linux-x64.tar.gz

    Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

    If you download it from web browser, in typical configuration the file will be saved to `~/Downloads` directory

    2. Extract JDK to Java's default location
    2. Open a terminal using Ctrl+Alt+T key combination

    3. Change a current directory to `~/Downloads`

    ```console
    $ cd ~/Downloads
    ```

    Extract JDK to Java's default location

    Create a jvm folder in /usr/lib/ which is the default location for Java.

  26. starlinq revised this gist Jul 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ The latest version is Java SE Development Kit 8u181

    The archive file is jdk-8u181-linux-x64.tar.gz

    If you download it from web browser, in typical configuration the file will be saved to ~/Downloads directory
    If you download it from web browser, in typical configuration the file will be saved to `~/Downloads` directory

    2. Extract JDK to Java's default location

  27. starlinq revised this gist Jul 18, 2018. 1 changed file with 66 additions and 1 deletion.
    67 changes: 66 additions & 1 deletion java-setup.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,69 @@
    test

    1. Download the latest JDK

    A current link is http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    The latest version is Java SE Development Kit 8u181

    The archive file is jdk-8u181-linux-x64.tar.gz

    If you download it from web browser, in typical configuration the file will be saved to ~/Downloads directory

    2. Extract JDK to Java's default location

    Create a jvm folder in /usr/lib/ which is the default location for Java.

    # sudo mkdir /usr/lib/jvm
    Go to the created /usr/lib/jvm folder.

    # cd /usr/lib/jvm
    Extract the downloaded JDK.

    # sudo tar -xvzf ~/Downloads/jdk-8u151-linux-x64.tar.gz
    Step 3: Set environment variables
    Edit the environment file.

    # vi /etc/environment
    Update the existing PATH variable by adding the below bin folders, separated with a colon :.

    /usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin
    HOME directory paths can be different based on version and update,here the version is 1.8 and the update is 151. Add the below variables at the end of environment file, making changes for your specific version and update.

    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre"
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
    The environment file should now be similar to this text:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin"
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
    J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre*
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
    DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"
    Save changes and close the file.

    Step 4: Inform Ubuntu about the installed location
    Use update-alternatives to inform Ubuntu about the installed java paths.

    # sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_151/bin/java" 0
    # sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_151/bin/javac" 0
    # sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_151/bin/java
    # sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_151/bin/javac
    Step 5: Setup verification
    Give the location of java and javac as you provided.

    # update-alternatives --list java
    # update-alternatives --list javac
    Restart the computer or open a new terminal.

    Step 6: Verify the Java version
    # java -version
    The output should resemble the following:

    java version "1.8.0_151"
    Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
    You should be able to see your installed java version which means you have successfully installed the Oracle JDK.



  28. starlinq created this gist Jul 18, 2018.
    4 changes: 4 additions & 0 deletions java-setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    test