I ran this command with apt-get but have received this error. I am not too sure how to resolve this. Is this come core mistake I have made using apt-get, asking for something impossible? Does anyone understand the root cause that prevents it from installing?
sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
openjdk-8-jdk : Depends: openjdk-8-jre (= 8u171-b11-1~bpo8+1) but it is not going to be installed
Depends: openjdk-8-jdk-headless (= 8u171-b11-1~bpo8+1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
An instance is a virtual machine (VM) hosted on Google's infrastructure. You can create an instance or create a group of managed instances by using the Google Cloud console, the Google Cloud CLI, or the Compute Engine API.
It's a one liner
sudo apt-get -y install default-jdk
java -version
I had a similar problem attempting to install the Java 8 JDK on one of my Google Compute Engine instances and found a solution here (but read about modifications below first):
http://cgrant.io/tutorials/gcp/compute/gce/how-to-deploy-a-java-application-to-google-compute-engine/
In the "Deploy scripts" section, inside the code block shown for install.sh, I pulled out the applicable lines and ran them with a few modifications as follows:
Here are the actual commands I was able to use to successfully install the Java 8 Open JDK:
# Grant yourself permission to the necessary directory
sudo chown $YOUR_USER_NAME /etc/apt/sources.list.d
sudo chgrp $YOUR_GROUP_ID /etc/apt/sources.list.d
sudo echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
sudo echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-get install dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo apt-get install openjdk-8-jdk -y --allow-unauthenticated
For the Oracle Java 8 JDK:
# Grant yourself permission to the necessary directory
sudo chown $YOUR_USER_NAME /etc/apt/sources.list.d
sudo chgrp $YOUR_GROUP_ID /etc/apt/sources.list.d
sudo echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
sudo echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-get install dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install oracle-java8-installer -y --allow-unauthenticated
At this point, if all went as intended, the following commands should produce something that looks a lot like:
$ javac -version
javac 1.8.0_171
$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-1~deb9u1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
Good luck and please let me know if this works for you. If not, I'd be happy to assist you further as needed.
Eric
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With