I've been trying to install the jdk on my ubuntu after downloading it.
first I've used: sudo apt-get update
then: sudo apt-get install jdk* (because I didn't want to write the whole long name).
it didn't work- printed the message in the title.
I thought the problem might me with the directory I'm executing from (I've executed it from the Downloads directory in which the file exists), so I've tried executing the same command (sudo apt-get install jdk*) from the home directory (root directory). Then it worked.. the whole installation took about 5 minutes and it looked like it was installing a lot of things I didn't ask for.
I wasn't sure it installed what I needed to I went back to the Downloads directory where the jdk8 package was located and like the first time ran the command from there. the same message as before... couldn't locate the package.
What have I done wrong ? Obviously it wasn't installed because when I've checked the version of java (java -version) it didn't show jdk8 was installed.
Thank you if you've taken the time to read to this point :)
解决方案
Command Line option - Ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Then in terminal
sudo apt-get install oracle-java8-installer
When there are multiple Java installations on your System, the Java version to use as default can be chosen. To do this, execute the following command.
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
Edit - Manual Java Installation
Download oracle jdk
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Extract zip into desired folder
e.g /usr/local/ after extract /usr/local/jdk1.8.0_65
Setup
sudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_65/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_65/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/local/jdk1.8.0_65/bin/javaws 1
sudo update-alternatives --set java /usr/local/jdk1.8.0_65/bin/java
sudo update-alternatives --set javac /usr/local/jdk1.8.0_65/bin/javac
sudo update-alternatives --set javaws /usr/local/jdk1.8.0_65/bin/javaws
Edit /etc/environment set JAVA_HOME path for external applications like Eclipse and Idea