I am trying to set the java version for a maven build when I execute it from a shell script. Fot some reason it is not picking up the intended java version. Any advise welcome.<
I found a solution:
If I set, this it works. Maven compiles the code.
<executable>/usr/lib/jvm/jdk-14.0.2/bin/javac</executable>
However, this is not ideal because the path to the install is hard-coded, so on other servers with a different JAVA_HOME location, it won't work. Is it possible to reference $JAVA_HOME
from within the POM file? and do something like this?
<executable><$JAVA_HOME>/bin/javac</executable>
e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${java.version}</release>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerVersion>${java.version}</compilerVersion>
<fork>true</fork>
<executable>/usr/lib/jvm/jdk-14.0.2/bin/javac</executable>
</configuration>
</plugin>