User Tools

Site Tools


Action disabled: revisions
software:java:start

Java

This is the procedure to (un)install Oracle Java SE.

  1. Download the binary code of JDK with extension .tar.gz.
  2. Extract its content.
  3. Run the following script to handle the complete (un)installation:
    java.sh
    #!/bin/bash
     
    clear
    echo "
    Please type:
    [i] for INSTALL 
    [u] for UNINSTALL
    [q] for EXIT
    "
    read opt
     
    if [[ $opt == i ]]
    then
        echo -e "Insert the full path of the java folder just extracted:\r"
     
        # save the name of the archive
        read java
     
        # create directory in the system and move files there
        sudo mkdir -p /usr/lib/jvm  
        sudo mv $java /usr/lib/jvm/
     
        # create symbolic links to the java files
        sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/java" 1
        sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/javac" 1
        sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/javaws" 1
        sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/jar" 1
     
        # make root the owner of this directory
        sudo chown -R root:root /usr/lib/jvm/$(ls /usr/lib/jvm)
     
        # enable the plugin for Mozilla Firefox
        # create directory
        mkdir ~/.mozilla/plugins
     
        # create symbolic links to the java files
        ln -s /usr/lib/jvm/$(ls /usr/lib/jvm)/jre/lib/*/libnpjp2.so ~/.mozilla/plugins/
     
    elif [[ $opt == u ]]
    then
        if [[ -e /usr/lib/jvm ]]
        then
            # delete symbolic links to the java files
            sudo update-alternatives --remove "java" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/java"
            sudo update-alternatives --remove "javaws" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/javaws"
            sudo update-alternatives --remove "javac" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/javac"
            sudo update-alternatives --remove "jar" "/usr/lib/jvm/$(ls /usr/lib/jvm)/bin/jar"
     
            # delete directory from the system
            sudo rm -rf /usr/lib/jvm
        fi
     
        if [[ -h ~/.mozilla/plugins/libnpjp2.so ]]
        then
            # remove plugin for Mozilla Firefox
            rm ~/.mozilla/plugins/libnpjp2.so
            empty=$(find ~/.mozilla/plugins -type d -empty | wc -l)
            if [[ $empty == 1 ]]
            then
                sudo rm -rf ~/.mozilla/plugins
            fi
        fi
     
    elif [[ $opt == q ]]
    then
        exit
     
    else
        echo "Invalid entry!"
    fi
software/java/start.txt · Last modified: 2023/05/28 16:37 by 127.0.0.1