1

I don't recall installing java on my Ubuntu 20.4 system, so I'm asking is there a way to know if it came pre-installed on the OS distribution. I usually, only expect the JRE to be installed not the JDK.

A search for the answer said that Ubuntu 20.04 includes Open JDK 11. But I seem to have Java JDK 8 installed.

java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~20.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

So I'm guessing that I installed it and just forgot that I did the install.

Alternatively, is there a way to know if java was installed using apt, ufw, yum, rpm or another package manager, or manually via cd /opt; tar xzf pkg.tgz.

What I've tried

Searching for an answer led me to this:

#1 ------------------------------------------------------------

apt list --installed | egrep -i 'jdk|java'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ca-certificates-java/focal,focal,now 20190405ubuntu1 all [installed,automatic]
gir1.2-javascriptcoregtk-4.0/focal-updates,focal-security,now 2.30.6-0ubuntu0.20.04.1 amd64 [installed,automatic]
java-common/focal,focal,now 0.72 all [installed,automatic]
javascript-common/focal,focal,now 11 all [installed,automatic]
libatk-wrapper-java-jni/focal,now 0.37.1-1 amd64 [installed,automatic]
libatk-wrapper-java/focal,focal,now 0.37.1-1 all [installed,automatic]
libjavascriptcoregtk-4.0-18/focal-updates,focal-security,now 2.30.6-0ubuntu0.20.04.1 amd64 [installed,automatic]
libjuh-java/focal-updates,focal-updates,now 1:6.4.6-0ubuntu0.20.04.1 all [installed,automatic]
libjurt-java/focal-updates,focal-updates,now 1:6.4.6-0ubuntu0.20.04.1 all [installed,automatic]
libridl-java/focal-updates,focal-updates,now 1:6.4.6-0ubuntu0.20.04.1 all [installed,automatic]
libunoloader-java/focal-updates,focal-updates,now 1:6.4.6-0ubuntu0.20.04.1 all [installed,automatic]
openjdk-8-jdk-headless/focal-updates,focal-security,now 8u282-b08-0ubuntu1~20.04 amd64 [installed,automatic]
openjdk-8-jdk/focal-updates,focal-security,now 8u282-b08-0ubuntu1~20.04 amd64 [installed]
openjdk-8-jre-headless/focal-updates,focal-security,now 8u282-b08-0ubuntu1~20.04 amd64 [installed,automatic]
openjdk-8-jre/focal-updates,focal-security,now 8u282-b08-0ubuntu1~20.04 amd64 [installed]

So I'm seeing [installed,automatic] and wondering if that is telling my that it was pre-installed (or came with the OS install).

#2 ------------------------------------------------------------

On some other Linux systems I've worked on they have used the alternatives command. See https://www.redhat.com/sysadmin/alternatives-command or https://linux.die.net/man/8/update-alternatives.

Below is a block quote from the linux.die.net website which is provided just in case the link stops working at some time in the future.

alternatives creates, removes, maintains and displays information about the symbolic links comprising the alternatives system. The alternatives system is a reimplementation of the Debian alternatives system. It was rewritten primarily to remove the dependence on perl; it is intended to be a drop in replacement for Debian's update-dependencies script. This man page is a slightly modified version of the man page from the Debian project.

#3 ------------------------------------------------------------

3
  • Try examining contents of file /var/log/dpkg.log ? And to see if the java package files have changed (e.g. via tarball) since it was first installed, try debsums <pkgname>
    – steve
    Commented Apr 5, 2021 at 19:54
  • @steve, Not much in dpkg.log (only 30 lines or so) and nothing with Java or JDK appearing and debsums was not installed.
    – PatS
    Commented Apr 5, 2021 at 20:08
  • (@steve+) also look at archived files dpkg.log.{1,2,...}{,.gz} [automatic] means a package was installed because something else depends on it -- notice openjdk-8-{jre,jdk}-headless and java-common are 'automatic' but openjdk-8-{jre,jdk} are not: the latter were explicitly installed and forced the installation of the -headless parts. Commented Apr 6, 2021 at 2:39

1 Answer 1

0

Ubuntu 20.04 come with openjdk 11 preinstalled. You have installed openjdk 8 manually using apt (or installation script) because the build number 1.8.0_282-8u282-b08-0ubuntu1~20.04-b08 indicate that the package belongs to Ubuntu repositories.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .