Install JDK on linux Ubuntu

Asked

Viewed 1,256 times

2

I’m trying to install JDK so I can install Netbeans.

Follow my attempt to install 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 from installation command:

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

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

Says it depends on the openjdk then I run the command to install:

sudo apt-get install openjdk-7-jre 

Out of command:

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

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

  • I’m not sure, but is the command not sudo apt-get install openjdk-7-jdk? From what I understand, he needs the development kit (JDK) not the Runtime (JRE)

  • @Gomiero ran this command and gave ( The following packages have uncompressed dependencies: openjdk-7-jdk : Depends: openjdk-7-jre (= 7u85-2.6.1-5) Recommends: libxt-dev but will not be installed E: Impossible to fix problems, you kept (hold) broken packages. )

  • I found this link that might help: How to install Java on Ubuntu with apt-get

  • 2

    Run on the terminal: sudo apt-get install -f and run the commands to install what you need again. One more thing, before running this command update your repository with sudo apt-get update.

  • When I used linux, I installed the oracle jdk, just add the PPA ppa:webupd8team/java and after updating the system repository, ran a apt-get install oracle-jdkX-installer where X is the version of JDK. Dai, ppa downloaded and installed both jdk and jre, and still logged in the browsers. I never had any problem in any of the verses of Ubuntu, from 8 to 14, which was the last one I installed.

  • apt-cache search jdk to see all jdk-related packages, select the latest one and do: sudo apt-get install pacoteatual, I believe that’s: sudo apt-get install oracle-jdk7-installer

Show 1 more comment

2 answers

2

  • Do the Download of .tar gz.

  • Execute the command tar 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/

  • Execute:

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 execution 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

  • The update-alternatives allows the installation of multiple versions and makes it possible to switch between them:

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

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

java -version

1

I use java from the Webupd8 repository. I have been using since Ubuntu 10.04 and have never had a problem.

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

To check if installed right:

java -version

And then:

javac -version

Done, just proceed with installing Netbeans.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.