JAVA_HOME not inherited from selected JDK

Hello,

We are building various product that use different version of JAVA:  Some legacy are using 1.8, current projects are using 1.8 and new projects are starting to use 11.

However, I'm having error.  Some Maven project use the fork parameter due to their size.  But Maven is using the JAVA_HOME, NOT the parent process, to determine which JDK to use for the forked process.

 

The build agent are started with JAVA_HOME set to Java 1.8

When an agent start a Java 11 build, maven start with the correct JDK. But when time come to fork, it inherit the agent's JAVA home and crash with the following error:

[Compiler] Compilation failure javac: invalid flag: --release Usage: javac <options> <source files> use -help for a list of possible options

I cannot simply start the agent with Java 11, as I'll get class not found when compiling Java 1.8 code due to the removal of JAVA EE.

 

Is there a way to have the agent use the selected JDK's home as  the JAVA_HOME rather then inherit the agent's JAVA_HOME without editing every single build definition?

4 comments
Comment actions Permalink

One possible workaround is to set JAVA_HOME environment variable in your build configuration and point it to correct version of JAVA. Something like:

env.JAVA_HOME=%env.JDK_11%

could work.

0
Comment actions Permalink

That would however require us to edit over a thousand build configurations.

Is there a way to make this the default behvior?

Shouldn't this be one of the variables set  when selecting a specific JRE?

0
Comment actions Permalink

I removed the JAVA_HOME declaration and replaced it by TEAMCITY_JRE as suggested, and restarted the agents.

Now, the agents are initializing the JAVA_HOME variable to the latest version of Java available.

0

Please sign in to leave a comment.