0

I need to cross-compile from sources this OpenJava fork https://gitlab.com/gosjava/11/openjdk/-/tree/master/ - for aarch64-linux-gnu devkit target: For that I installed java 10.0.2 as host JDK then ran "./configure"

└─$ ./configure    
...
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
checking for javac... /home/katya/java/bin/javac
checking for java... /home/katya/java/bin/java
configure: Found potential Boot JDK using java(c) in PATH
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: Could not find a valid Boot JDK. You might be able to fix this by running 'sudo apt-get install openjdk-8-jdk'.
configure: This might be fixed by explicitly setting --with-boot-jdk
configure: error: Cannot continue
configure exiting with result code 1

Full log here https://gist.github.com/iva-nova-e-katerina/3061b865beb48dc25594bc360508d6a3 Could you tell me why the configure said that I use wrong JDK?

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183

3 Answers3

5

That message is being generated by the BOOTJDK_DO_CHECK autoconf macro whose definition is in "jdk11u/make/autoconf/boot-jdk.m4". If you look at the file you will see the following:

      BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`

      # Extra M4 quote needed to protect [] in grep expression.
      [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
          | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
      if test "x$FOUND_CORRECT_VERSION" = x; then
        AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect
                       JDK version ($BOOT_JDK_VERSION); ignoring])
        AC_MSG_NOTICE([(Your Boot JDK version must be one of:
                       $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
        BOOT_JDK_FOUND=no

(I've added a couple of line breaks for readability ...)

If we compare this to the actual error message:

configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version 
(Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); 
ignoring

So ... it looks like:

  1. You have (or something has) set the _JAVA_OPTIONS environment variable in the environment that is in effect when you run configure.
  2. The java command is warning you that _JAVA_OPTIONS are in effect (for security reasons!). Presumably the real version string gets output as the next line.
  3. The macro captures just the first line (head -n 1) ... and then uses the warning message as if it was the real version string.
  4. This bogus version causes the Boot Java version checking logic to fail.

You probably have a valid Boot JDK ... but configure has been confused by the warning message, and thinks that you don't.

Possible solutions:

  • Just unset _JAVA_OPTIONS. Those options don't look relevant to what you are doing.

  • If the are relevant to building, unset _JAVA_OPTIONS while you run configure. Then set it again.

  • If there is some reason why unsetting _JAVA_OPTIONS won't work, you could modify the above ".m4" file to skip the version check. (Ughhh ...)


You can read more about this unwanted (though actually necessary) behavior of _JAVA_OPTIONS in:

(And the short answer is "you can't" ... apart from unsetting the environment variable.)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
2

install OpenJDK binaries at, say /opt/jdk-bin Then,

./configure --with-boot-jdk=/opt/jdk

and that's it!

piiabo
  • 31
  • 2
  • 1
    I have a feeling this would not fix the OP's problem. Can you confirm that this will work if `_JAVA_OPTIONS` is set? – Stephen C Jun 26 '22 at 12:14
0

Well, I am building Linux systems by checking my ideas. So it is not about feelings. It is about checking and rechecking them. That's the only way to learn. Anyhow, building OpenJDK is nontrivial and requires some work. So

build/.configure-support/generated-configure.sh ... You have JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build

is irrelevant to Catherine's question.

configure: This might be fixed by explicitly setting --with-boot-jdk

happened to me, so I found the above solution. It did solve the problem and the build went through. Alas, as Linux has its own mysterious ways, this mornging I rechecked and surprisingly configure went through smoothly but the build failed on account warrnings being treated as errors. This is resolved by

vi build/linux-x86_64-server-release/spec.gmk

and deleting the occurences of -Werror in there and everything went through just fine.

piiabo
  • 31
  • 2