0

I want to start learning Java, and I tried to download jdk and also other stuff that is helpful with Java, but I cant find the exact command to install oracle Java through terminal or in any other way. How can I do that?

Zanna
  • 70,465
BIRUK
  • 1
  • First complete remove java if installed on system using this :http://stackoverflow.com/questions/32565225/how-do-i-completly-remove-openjdk-from-redhat/32932707#32932707 – Nullpointer Feb 27 '17 at 07:10
  • By the way, for most purposes you can use OpenJDK instead of Oracle's version. – Zanna Feb 27 '17 at 07:10
  • It's not necessary but if previously installed on system then may trouble to install it. Can you update the question with more details(with error) – Nullpointer Feb 27 '17 at 07:18

2 Answers2

0

First, you should uninstall all "java" packages from your system.

After that, download the most recent Oracle Java JDK from here for your architecture (32bit or 64bit, you can find that out with executing the arch command in a terminal. Then unzip the ".tar.gz" (should work with your archive manager) and move it to some location like /opt/jdk8.

If you want to make the execution of java more comfortable (at this point, you'd have to type e.g. /opt/jkd8/bin/java -version), you should add the line PATH=/opt/jdk8/bin:"$PATH" in the file in /etc/profile.

Then just execute Java with java %command%.

Have fun with Java, it's a great programming language!

Cheers, Ignatiamus

0

The best way to install Java is to use the repository and install the version from the repository. It's called Openjdk. You can install it with this commandline:

$ sudo apt install default-jdk

If you have more than one version installed you can switch between version (or verify the version you are running) with this command:

$ sudo update-alternatives --config java

You will either see a message indicating that you just have one version installed, or you'll receive a list of version with the option to choose which installed version to make active.

Since you specifically asked about Oracle Java Jdk, you can do this seamlessly by adding a PPA repository. Then running the Apt install command. These are the steps:

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

The installers will override what your previous attempts.

It's helpful to update and upgrade your repository cache and libraries when installing applications from the commandline. You can do this with these commands:

$ sudo update
$ sudo apt upgrade

Also, when prompted from the command output, you can remove unused libraries that are no longer used on the system with:

$ sudo apt autoremove
L. D. James
  • 25,036