1

How do I check whether the installed JRE is JRE-headless or the FULL-JRE?

As headless-JRE's are lightweight and they do not contain dependencies for GUI components, they are preferred for server applications and embedded systems.

Patrick
  • 1,728
  • 2
  • 17
  • 30
thebytewalker
  • 316
  • 4
  • 15
  • [This](https://stackoverflow.com/a/16611566/133203) may give you ideas. – Federico klez Culloca Jul 17 '18 at 08:07
  • [GraphicsEnvironment isHeadless()](https://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsEnvironment.html#isHeadless()) – khelwood Jul 17 '18 at 08:08
  • 3
    Possible duplicate of [Is there a safe, programmatic way to determine if it's safe to open a Swing window?](https://stackoverflow.com/questions/5893236/is-there-a-safe-programmatic-way-to-determine-if-its-safe-to-open-a-swing-wind) – Florian Albrecht Jul 17 '18 at 08:08

1 Answers1

1

As this question doesn't seem to ask for a code-snippet and I was looking for a way to simply be able to tell if a Java-installation supports GUI or not and (at least my) Google doesn't have an answer for that, my current wisdom is to check what's installed.

I'm not sure, but I think on Windows there's a command javaw if Java supports GUI. On Linux one has to check what's installed:

[root@host ~]# yum list "*jdk*"
Last metadata expiration check: 4:50:52 ago on Wed 15 Mar 2023 05:08:08 CET.
Installed Packages
copy-jdk-configs.noarch             4.0-2.el8
java-1.8.0-openjdk.x86_64           1:1.8.0.362.b09-2.el8_7
java-1.8.0-openjdk-headless.x86_64  1:1.8.0.362.b09-2.el8_7
Available Packages
...
[root@host ~]#

So the Java on this machine would provide a GUI as java-1.8.0-openjdk.x86_64 is installed. If it would only show java-1.8.0-openjdk-headless.x86_64 there won't be a GUI-mode.

However, I don't see how I could tell it by showing the version as the output is the same for GUI and headless:

[user@host bin]$ java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
[user@host bin]$
sjngm
  • 12,423
  • 14
  • 84
  • 114