Find installed applications, that need JAVA

I’m having issues with JAVA versions, as application 1 does not allow JAVA 22, application 2 wants JAVA >=17 and so on. In order to keep my java versions up-to date, I d like to find all installed applications, that need JAVA.

$ pacman -Qqe

shows a list of all applications installed. The commands

$ jps -m
$ ps aux | grep java

both are listing running JAVA-applications.
How (with a bash script?) can I find the installed applications, that need JAVA?

I would have made a oneliner for you but i have to catch a plane now :slight_smile:
Generally speaking, man pacman, man expac and man grep are your friends.
Filtering the output of expac would probably be the easiest.
The real question is - why do you have such an app. If something requires old versions it is most probably an aur build - and those are not officially supported and up to you to debug.

1 Like

I have no real clue about this (never used expac before but happy to know about it now), but I wonder if @Teo was thinking about using something like this

expac -Q '%r/%n %v %E' | grep java-environment

On my laptop this gives this list which does look half-way plausible for the things I have installed

local/gradle 8.10-1 java-environment  bash  which  coreutils  findutils  sed
local/java-environment-common 3-5 
local/jdk17-openjdk 17.0.12.u7-1 java-runtime-common  ca-certificates-utils  nss  libjpeg-turbo  libjpeg.so  lcms2  liblcms2.so  libnet  freetype2  libfreetype.so  harfbuzz  libharfbuzz.so  glibc  gcc-libs  java-environment-common  hicolor-icon-theme  libelf  libgif.so  libpng  ca-certificates-utils  nss  libjpeg-turbo  libjpeg.so  lcms2  liblcms2.so  libnet  freetype2  libfreetype.so  harfbuzz  libharfbuzz.so
local/jdk21-openjdk 21.0.4.u7-1 java-runtime-common  ca-certificates-utils  nss  libjpeg-turbo  libjpeg.so  lcms2  liblcms2.so  libnet  freetype2  libfreetype.so  harfbuzz  libharfbuzz.so  glibc  gcc-libs  java-environment-common  hicolor-icon-theme  libelf  libgif.so  libpng  ca-certificates-utils  nss  libjpeg-turbo  libjpeg.so  lcms2  liblcms2.so  libnet  freetype2  libfreetype.so  harfbuzz  libharfbuzz.so
local/visualvm 2.1.8-1 java-environment

But I don’t know if that helps you, since as @Teo said your real problem may lie elsewhere.

In the meantime, I wonder why I appear to have two versions of openjdk? :thinking:

1 Like

Find java packages installed:

pacman -Qs java

List tree of installed packages depending on java-package:

pactree -r java-package

(pactree is from pacman-contrib package)

2 Likes

Thanks a lot for all replies @Teo, @Phemisters and @cscs and a warm welcome to Phemister!
In order to see the installed applications (not the JAVA versions) I modified the command to

$ expac -Q    '%r/%n %v %E' | grep java
$ expac -Q -S '%r/%n %v %E' | grep java

Unfortunately I do not understand the options, but obviously I need both: Some applications (dBeaver) showing up with both commands, others either with the first or the second.

The proposal from cscs

$ pacman -Qs java

provides a list similar to

$ expac -Q '%r/%n %v %E' | grep java

but f.e. dBeaver is not showing up here. After that

$ pactree -r "jdk-openjdk"

is showing dbeaver. Very confusing for myself …

$ expac -Q -S ‘%r/%n %v %E’ | grep java

I think that -Q searches the local database and -S the sync one, so using both will be searching two databases. I don’t know for sure what local and sync mean in this context but my first guess was that local was what I had installed and sync was what was available (including things not yet installed). But as I say, I’m guessing.

What issues? :thinking:

No one should have to poke and prod you to extract information you should have already provided to begin with. Help us help you.

Please see:

Everything said, is the (more) correct way to do this. These all assume the pacman db is in sync with your FS. And don’t include downloaded files, or anything outside the package database.

But if you want to tackle this from a different angle, which is not fool-proof, and a little bit hacky.

sudo find / -mount -exec file {} \; | grep ': Java '

It is trusting the file command to identify each file on your filesystem if it’s a Java source file, complied file, JARs, and others. Then I just grep for it.

This will take some time, reading every file on your root filesystem. And you will find a lot of files Manjaro puts in, especially in /usr/share, which you can just exclude.

But I thought I’d throw this out there, to use in addition to the above. To track down rogue Java files.

Of course it does.
The expac command is a bit silly for the question … it prints all installed packages

  • repo
  • package name
  • version
  • and the packages they depend on

Then it greps ‘java’.

Thats a bit different, but quite similar, to something like

pacman -Qi | grep java

https://man.archlinux.org/man/expac.1

The only package(s) that require jdk-openjdk is dbeaver.

1 Like

Indeed, pactree -r jdk-openjdk OR pactree -r jre-openjdk is all that is needed in that case.
Note that it looks for installed packages. If you directly downloaded jar files in home it is another story.

1 Like