0

On FreeBSD 12, I already installed Java 12 successfully using:

sudo pkg install openjdk12

And I edited etc/fstab as directed by the text emitted by that installer.

Then I set the PATH to include the Java bin folder by editing my .zshrc with the line path+=/usr/local/openjdk12/bin. I verified that java --version works.

Then I go to install Apache Tomcat 9. I checked with Ports to see there is an entry for the latest version, Tomcat 9.0.22. So I run:

sudo pkg install tomcat9

I quickly notice this output during the installation:

[2/9] Fetching openjdk8-8.212.4.1.txz: 100% 80 MiB 83.4MB/s 00:01

Whoa, hold up there. I did not want the old OpenJDK 8 installed. I want Tomcat to be using that OpenJDK 12 I installed.

➥ How can I avoid installing OpenJDK 8, and instead direct the installer (if relevant) and Tomcat itself to use my OpenJDK 12?

  • 1
    Unfortunately, the dependencies of packages are hardwired to the prevalent versions. Generally, ports are more flexible and you should be able to install tomcat9 with whichever JDK you've previously installed. – Richard Smith Jul 25 '19 at 20:36
3

When pre-built binary packages don't meed your needs, it pays to consider ways to build what you need from source via FreeBSD's extensive ports system.

Some FreeBSD ports support a make config target that allows you to select from various dependency options, but alas, tomcat9 doesn't have many configuration knobs that one can tweak.

FreeBSD ports also support the make missing target to tell you what required ports or packages aren't already installed. For convenience, I will sort the make output:

# cd /usr/ports/www/tomcat9
# make missing | sort
archivers/zip
converters/p5-Text-Unidecode
devel/autoconf
devel/autoconf-wrapper
devel/jakarta-commons-daemon
devel/m4
devel/p5-Locale-gettext
devel/p5-Locale-libintl
java/bootstrap-openjdk8
java/java-zoneinfo
java/javavmwrapper
java/openjdk8
misc/help2man
print/texinfo
textproc/p5-Unicode-EastAsianWidth

Let's look at the devel/jakarta-commons-daemon dependency and do the same thing there:

# make -C ../../devel/jakarta-commons-daemon missing | sort
archivers/zip
converters/p5-Text-Unidecode
devel/autoconf
devel/autoconf-wrapper
devel/m4
devel/p5-Locale-gettext
devel/p5-Locale-libintl
java/bootstrap-openjdk8
java/java-zoneinfo
java/javavmwrapper
java/openjdk8
misc/help2man
print/texinfo
textproc/p5-Unicode-EastAsianWidth

Close inspection of those lists shows that devel/jakarta-commons-daemon is the only entry not in both lists.

In other words, tomcat9 has only one (missing) dependency: devel/jakarta-commons-daemon itself. All the other missing bits of tomcat9 are in fact dependencies of devel/jakarta-commons-daemon. So your question becomes, "How can I build the port for devel/jakarta-commons-daemon using jdk12 instead of the default jdk8?" A question I can't answer, to be sure, but I hope you will get some benefit from having a more precisely targeted question.

FreeBSD has a java-specific mailing list. You can sign up here. A clear, documented question that shows research and effort is most likely to get a response. That is where I'd wager you are most likely to find someone who knows the answer to your question. If you do find out, please come back here and post it as an answer, so that future StackExchange readers can benefit from your efforts.

You may also be interested in adding your email as a CC: on this FreeBSD Bugzilla entry to stay abreast of development work to improve support for recent versions of the Java Development Kit.

1

You can also try doing pkg fetch tomcat9 and then pkg add -M /var/cache/pkg/tomcat9.txz to install tomcat9 without pulling its dependencies.

  • Unfortunately, running pkg fetch tomcat9 results in 2 ambiguous items in /var/cache/pkg/: tomcat9-9.0.21-6644990766.txz & tomcat9-9.0.21.txz. – Basil Bourque Jul 30 '19 at 0:56
  • Furthermore, trying sudo pkg add -M /var/cache/pkg/tomcat9-9.0.21.txz results in errors: pkg: Missing dependency 'jakarta-commons-daemon' and pkg: Missing dependency 'openjdk8' – Basil Bourque Jul 30 '19 at 1:00
  • tomcat9-9.0.21.txz is just a symlink to tomcat9-9.0.21-6644990766.txz, so that's OK. As for missing dependency error, with -M flag these are just warnings, and the package itself got installed. Check pkg info tomcat9 to see if it is installed. – arrowd Jul 30 '19 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.