Installing JDK on ubuntu linux

2

I'm trying to install the JDK in order to install NetBeans.

Here is my attempt to install the JDK:

Java version (Java -version):

  

java version "1.7.0_95" OpenJDK Runtime Environment (IcedTea 2.6.4)
  (7u95-2.6.4-0ubuntu0.15.10.1) OpenJDK 64-Bit Server VM (build   24.95-b01, mixed mode)

JDK installation command:

sudo apt-get install default-jdk

Exit installation command:

  

kleber @ magneto: ~ $ sudo apt-get install default-jdk
  Reading lists of   packages ...   Ready Building dependency tree
  Reading status information ...   Ready Some packages could not be installed. This may mean that you have requested a   impossible or, if you are using the unstable distribution, that some   packages have not been created yet or have been removed from the   "Incoming." The following information can help resolve the situation:

     

The following packages have mismatched dependencies: default-jdk:   Depends: openjdk-7-jdk (> = 7 ~ u3-2.1.1) E: Impossible to fix   problems, you kept (hold) broken packages.

It says it depends on openjdk then I execute the command to install:

sudo apt-get install openjdk-7-jre 

Command Output:

  

kleber @ magneto: ~ $ sudo apt-get install openjdk-7-jre Reading lists of   packages ... Ready Building dependency tree Reading   status info ... Ready openjdk-7-jre is already the newest version.   0 packages upgraded, 0 new packages installed, 0 to be removed   and 0 not updated.

Does anyone know what I should do to get JDK installed?

    
asked by anonymous 17.02.2016 / 18:50

2 answers

2
  • Download for .tar.gz

  • Run the tar command to unzip the downloaded file:

  

tar -xvf jdk-8u77-linux-i586.tar.gz

  • Now create a folder and move the unzipped files to the created folder:
  

sudo mkdir -p / usr / lib / jvm
   sudo mv ./jdk1.8.0 / usr / lib / jvm /

  • Run:
  sudo update-alternatives --install "/ usr / bin / java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1
  sudo update-alternatives --install "/ usr / bin / javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1
  sudo update-alternatives --install "/ usr / bin / javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1

  • Run the command below to apply the execute permissions:
  

sudo chmod a + x / usr / bin / java
  sudo chmod a + x / usr / bin / javac
  sudo chmod a + x / usr / bin / javaws
  sudo chown -R root: root /usr/lib/jvm/jdk1.8.0

  • update-alternatives allows you to install multiple versions and switch between them:
  

sudo update-alternatives --config javac
  sudo update-alternatives --config javaws

  • Run the command below to verify the installation and version that is in use:
  

java -version

    
09.06.2016 / 19:41
1

I use the java from the WebUpd8 repository. Use since Ubuntu 10.04 and never had a problem.

sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer

To verify that you have installed it correctly:

java -version

And then:

javac -version

Done, just proceed with the installation of NetBeans.

    
09.06.2016 / 19:51