Install Java on Ubuntu server (Parallels Plesk)

6,370

Download the Oracle java from its offical website

Download Java From Official website Here

Manually Install the JDK 1.7

#java -version

#sudo mkdir -p /usr/lib/jvm

#sudo mv jdk-7u21-linux-i586.tar.gz /usr/lib/jvm

#cd /usr/lib/jvm

#sudo tar zxvf jdk-7u21-linux-i586.tar.gz

#sudo rm jdk-7u21-linux-i586.tar.gz

#ls -l

#jdk1.7.0_21

#sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_21/bin/javac" 1

#sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_21/bin/java" 1

#sudo update-alternatives --set "javac" "/usr/lib/jvm/jdk1.7.0_21/bin/javac"

#sudo update-alternatives --set "java" "/usr/lib/jvm/jdk1.7.0_21/bin/java"

#sudo vi /etc/profile

Add the following entries to the bottom of your /etc/profile file:

#JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21 PATH=$PATH:$JAVA_HOME/bin export JAVA_HOME export PATH

#. /etc/profile

#java -version

Replace the jdk1.7.0_21 With the version u have Downloaded

Share:
6,370

Related videos on Youtube

atMaarten
Author by

atMaarten

Updated on September 18, 2022

Comments

  • atMaarten
    atMaarten over 1 year

    I want to install Java to my server so I can use PHP shell_exec to compile Java online. So I'm trying to install Java on my webserver (Ubuntu - Parallels Plesk). I logged in to the server with PuTTY and tried some commands like:

    sudo apt-get install openjdk-6-jre
    

    or

    sudo apt-get install oracle-java7-installer
    

    But than I get error's like:

    Package drweb-bases must be reinstalled, but there can be no archive found.
    

    I tried to uninstall drweb-bases, reinstall, no matter what. I still get that error. What you I need to do? I am doing it completly wrong? Am I not destroying my webserver? There is not much to find on this topic on Google.

    • Anwar
      Anwar over 10 years
      If you need jdk, install openjdk-7-jdk package, provided you don't need specifically the oracle jdk.
    • atMaarten
      atMaarten over 10 years
      I just want to install Java to my server so I can use PHP shell_exec to compile Java online.
  • atMaarten
    atMaarten over 10 years
    That worked out great! java -version now gives in PuTTY the current java version back and I can compile and stuff. However when using $output = shell_exec('javac -version'); echo "<pre>$output</pre>"; in PHP it returns nothing nor it will compile. Any Thoughts?