Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an ubuntu system and I want to replace my openjdk with oracle-jdk.

However if I remove my open-jdk and then install oracle-jdk, when I try to install some packages they want to install openjdk and I don't want this.

Is there any way to install those packages on top of oracle-jdk? One of those packages is freemind.

share|improve this question

migrated from stackoverflow.com Mar 6 at 17:22

This question came from our site for professional and enthusiast programmers.

    
Which packages require open-jdk that you want to install? (besides freemind) –  Seth Mar 6 at 17:24

3 Answers 3

up vote 7 down vote accepted

You can completely remove the OpenJDK and fresh Install Oracle Java JDK by the following steps:

  1. Remove OpenJDK completely by this command: sudo apt-get purge openjdk-\*
  2. Download the Oracle Java JDK here.

    Note: download appropriate file, for example if your system is x64 Ubuntu (i.e, Debian) the download file is named like this: jdk-8u20-linux-x64.tar.gz

  3. Create a folder named java in /usr/local/by this command: sudo mkdir -p /usr/local/java

  4. Copy the Downloaded file in the directory /usr/local/java. To do this, CD into directory where downloaded file is located and use this command for copying that file to /usr/local/java/:

    sudo cp -r jdk-8u20-linux-x64.tar.gz /usr/local/java/

  5. CD into /usr/local/java/ directory and extract that copied file by using this command:

    sudo tar xvzf jdk-8u20-linux-x64.tar.gz

  6. After extraction you must see a folder named jdk1.8.0_20.

  7. Update PATH file by opening /etc/profile file by this command: sudo nano /etc/profile and paste the following at the end of the file:

    JAVA_HOME=/usr/local/java/jdk1.8.0_20
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    export JAVA_HOME
    export PATH
    
  8. Save and exit.

  9. Tell the system that the new Oracle Java version is available by the following commands:

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_20/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_20/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_20/bin/javaws" 1
    
  10. Make Oracle Java JDK as default by this following commands:

    sudo update-alternatives --set java /usr/local/java/jdk1.8.0_20/bin/java
    sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_20/bin/javac
    sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_20/bin/javaws
    
  11. Reload sytem wide PATH /etc/profile by this command: source /etc/profile

  12. Reboot your system.
  13. Check Java JDK version by this command: java -version . If installation is succesful, it will display like the following:

    java version "1.8.0_20"
    Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
    Java HotSpot(TM) Server VM (build 25.20-b23, mixed mode)
    

That's it!

Note: We Assumed that the downloaded file is named jdk-8u20-linux-x64.tar.gz and used this name in all the commands used in steps 2, 4 and 5. It may depends on the type of O.S, processor type (i.e., 32bit or 64bit)

share|improve this answer

You don't need to remove openjdk in order to use / install the oracle's jdk. Just install the oracle's jdk and configure which java you want to use by configuring it with:

sudo update-alternatives --config java

You can find more help here: https://help.ubuntu.com/community/Java

share|improve this answer
    
I need a way to have only one java on my ubuntu. tnx. –  little ali Mar 6 at 11:48

After removing openjdk, try this approach that worked for me:

Install oracle jdk 7 on ubuntu server (tested with ubuntu 12.0.4)

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

some more info here: https://launchpad.net/~webupd8team/+archive/java

(note to adapt this for your version of jdk)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.