Do I need to install jdk and jre in the same directory?

Viewed 247

I first installed jre version 8 on Ubuntu in this directory : /usr/local/java , now I want to install Oracle JDK version 8, do I have to install Oracle JDK in a directory similar to jre? And is it better to uninstall jre? And just install jdk?

2 Answers

You haven't to choose the directory, just do:

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

It installs both jre and jdk.

If you see this error:
E: Package 'oracle-java8-installer' has no installation candidate

You can download the last Oracle JDK 8 here:
https://www.oracle.com/java/technologies/javase-downloads.html#javasejdk
and perform a manual install. Be aware of the licensing terms; they may require a fee for use in production. Other vendors offering implementations of Java include Azul Systems, Adoptium/AdoptOpenJDK, RedHat/IBM, Amazon, Microsoft, SAP, Pivotal, and BellSoft.

And, as duffymo said, the JDK contains a JRE.

See the answer totally depends upon your use case. JRE is usually meant for higher development environments like Android. JDK is suitable for high school level code, and for running operations on-computer. Usually the software you are using for development will come with JRE if it needs one so you don't need to download it manually. So I guess it's okay to uninstall the JRE. Keep the JDK wherever you want, but if you wish to use it from the command line you need to add a JAVA_HOME variable to the system variables. Oh I think I drifted towards Windows.

Related