Problems with java >= 1.8 requirement

For formula such as sbt or scala, there is a requirement of java >= 1.8. The test for this requirement seems to be broken for the latest version of java 8, as well as not being good enough to identify alternate JDK providers which are likely to be more common.

I have Java 8 installed using the java8 cask from homebrew-cask-versions. My JAVA_HOME is set to that location: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

I also have a Java 11 JDK provided by the adoptopenjdk cask. If I change my JAVA_HOME to /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home that is also not recognized as meeting the >= 1.8 requirement.

Using brew irb and running JavaRequirement.new(%w[1.8+]).send("possible_javas") gives:

=> [#Pathname:/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java]

Which then doesn’t work with the version parsing. So that makes sense. And since my JAVA_HOME is set locally in my shell, maybe it doesn’t pick it up in the context that brew runs. Should brew pick up my JAVA_HOME from when I run it, or does it load the environment from somewhere else? Other than uninstalling adoptopenjdk version 11, how can I make homebrew aware of the java8 version I have installed?


Edit: Wrapped your command line in “`”s to keep Discourse from modifying quotation marks.@claui

Did you ever figure this out? I’m running into what I think is the same problem with adoptopenjdk and jenkins - brew doesn’t recognize that the java requirement is being met.

Which formula @joshualoving?

I’m testing locally with scala/sbt to see if I can reproduce this

I’m having this problem with both the jenkins and jenkins-lts formulas. I’m on linuxbrew though, so I may need to take my questions elsewhere.

@jrduncans: Some changes were made to homebrew, possibly after your post, to switch to adoptopenjdk as the default Java for formula with java requirements. I am no java dev, but I’m currently unable to reproduce your issue. For me, brew irb:

JavaRequirement.new(%w[1.8+]).send("possible_javas")
=> [#<Pathname:/Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home/bin/java>]

and brew install, brew test and brew audit all work for scala and sbt.

The Homebrew environment is intentionally sanitized to ensure builds are not influenced by strange or unexpected things in the users environment. If you want to poke around the build environment you can try, e.g., brew install --build-from-source --interactive scala. I’d recommend disabling your .bashrc file and maybe .bash_profile/.profile as your local shell will have some stuff from these when homebrew launches bash after dropping you into the sanitized environment and bash may source some of your dot files that would not be source during a normal install.

For my, I do not have JAVA_HOME set in my environment and Homebrew sets it correctly to find adoptopenjdk.

I’m also seeing a problem with logstash, that maybe is part of this same larger problem - logstash requires openjdk, and I’m guessing that at some point it will be switched to requiring adoptopenjdk and hasn’t been switched yet?

Yes @zbeekman, since my post I have tried with adoptopenjdk and adoptopenjdk11 and things work now for me.

1 Like