I am interested in a headless build of openjdk11 to use in a server environment but it seems there are no build configuration options available. java/openjdk8 has --disable-headful to build a headless binary and a nice `make config` UI, but it seems the openjdk11 build is unconfigurable. This is a request for a build configuration option for headless openjdk11. Thanks
Won't work: ====================== ... checking how to link with libstdc++... static configure: error: It is not possible to disable the use of X11. Remove the --without-x option. configure exiting with result code 1 ===> Script "configure" failed unexpectedly. Please report the problem to java@FreeBSD.org [maintainer] and attach the "/var/tmp/freebsd-ports/java/openjdk11/work/jdk11u-jdk-11.0.15-10-1/config.log" including the output of the failure of your make command. Also, it might be a good idea to provide an overview of all packages installed on your system (e.g. a /usr/local/sbin/pkg-static info -g -Ea). *** Error code 1 Stop. make: stopped in /var/tmp/freebsd-ports/java/openjdk11 ====================== from: ./work/jdk11u-jdk-11.0.15-10-1/make/autoconf/libraries.m4: ====================== 40 AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES], 41 [ 42 # Check if X11 is needed 43 if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then 44 # No X11 support on windows or macosx 45 NEEDS_LIB_X11=false 46 else 47 # All other instances need X11, even if building headless only, libawt still 48 # needs X11 headers. 49 NEEDS_LIB_X11=true 50 fi ======================
(In reply to Michael Osipov from comment #1) Headless should work, but it will still need some components of X11 to be installed.
Openjdk11 and openjdk17 seems to have a new configure option --enable-headless-only. Didn't check openjdk21. In this mail is talks about the introduction of this option: https://mail.openjdk.org/pipermail/2d-dev/2016-August/007382.html Openjdk11 pkg builds fine if I add CONFIGURE_ARGS+=--enable-headless-only to the port. I didn't check running it. And I didn't check how the dependencies of the openjdk11 need to change for an headless build. Would it be enough to adapt these Makefile statements to the openjdk11 Makefile? $ grep X11 /usr/ports/java/openjdk8/Makefile OPTIONS_DEFINE= ALSA POLICY TZUPDATE X11 FONTCONFIG OPTIONS_DEFAULT= ALSA POLICY TZUPDATE X11 X11_BUILD_DEPENDS_OFF= ${LOCALBASE}/include/X11/Xlib.h:x11/libX11 \ ${LOCALBASE}/include/X11/extensions/Xdbe.h:x11/libXext \ ${LOCALBASE}/include/X11/extensions/Xrender.h:x11/libXrender \ ${LOCALBASE}/include/X11/Intrinsic.h:x11-toolkits/libXt X11_CONFIGURE_OFF= --disable-headful X11_CONFIGURE_ON= --with-giflib=system \ X11_LIB_DEPENDS= libgif.so:graphics/giflib X11_MAKE_ENV_OFF= BUILD_HEADLESS_ONLY=1 \ X11_USES= xorg X11_USE= XORG=x11,xext,xi,xrender,xt,xtst FONTCONFIG_IMPLIES= X11 Anyway.. I have no personal interest in adding this to the port. As this issue is 2 years old I would like to know if the original requester is still interested or if other people know if this is still wanted? Patches are welcome.
I'd be happy to have this, but I won't pursue a patch. Maybe the reporter can work on a patch.
(In reply to Michael Osipov from comment #4) Still interested! Just not familiar with makefiles enough to magic this together myself
The OpenJDK v25 port added a headless flavor: https://reviews.freebsd.org/D53450 This can be closed.
(In reply to Ryan Shaw from comment #5) I'd be interested to know if the current openjdk25 port works for you. I will probably back port it to at least the more recent jdk versions, but it would be good to know if there's anything not working before I do that :)
How much space does one save on disk? and the other question is whether this makes java.awt.headless property obsolete?
(In reply to Michael Osipov from comment #8) The size of the installed jdk is not significantly smaller. It's only the libawt_xawt.so not being built. But it saves you some dependencies. I haven't measured the total size difference including dependencies. The java.awt.headless property is still there, but since the x11/xorg support is not, it's not really needed. I.e. java.awt.GraphicsEnvironment.isHeadless() will always return true. https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/java/awt/GraphicsEnvironment.html#isHeadless() It's worth noting that this only concerns GUI apps using awt. Other toolkits like swt that is not based on awt are still able to display as normal. It may be possible to build a headless JRE, that will save more space on disk as long as you don't need the full jdk (javac, jdb etc.)
(In reply to Harald Eilertsen from comment #9) I'd like a headless JRE.
(In reply to Yonas Yanfa from comment #10) Me as well. I have deployments which just need a JRE, e.g. webapps on Tomcat.
(In reply to Michael Osipov from comment #11) > (In reply to Yonas Yanfa from comment #10) Allright, I'll see if I can make that work.
Patch to add `jre_headless` flavor here: https://reviews.freebsd.org/D53707
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=558ad9ce89912a8c688d03c7e2560b55d49c5541 commit 558ad9ce89912a8c688d03c7e2560b55d49c5541 Author: Harald Eilertsen <haraldei@FreeBSD.org> AuthorDate: 2025-11-12 13:39:14 +0000 Commit: Harald Eilertsen <haraldei@FreeBSD.org> CommitDate: 2025-11-25 13:44:21 +0000 java/openjdk25: Add jre_headless flavor Add flavor to make a headless jre package, where dev tools and x11 support is removed. As requested in Bug #266059. PR: 266059 Reviewed by: fuz, jrm Approved by: fuz (Mentor), jrm Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53707 java/openjdk25/Makefile | 50 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-)