I have some projects compiled and deployed with Maven and Jenkins and they have worked fine until now that I have changed the java version from 6 to 7.
In order to do this I executed the command sudo update-alternatives --config javac and changed the values of JAVA_HOME and PATH in the /etc/profile file. I have also modified the pom file so it uses jdk 1.7:
<properties>
...
<jdk.version>1.7</jdk.version>
</properties>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
...
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
When I execute them on the console they compile fine and the displayed version is correct:
javac -version
javac 1.7.0_55
mvn install -debug
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.7.0_55
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
However, when I do the same in a jenkins job, Maven uses the 1.6 version instead of 1.7:
javac -version
javac 1.7.0_55
mvn install -debug
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.6.0_31
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
I have also modified the maven configuration file that I use to indicate the new version, and in the Jenkins administration panel I have changed the JDK version. However, Maven is still using the 1.6 jdk.
Do you know how can I change it?
I found the solution here. It is necessary to define the JAVA_HOME variable also in the global configuration of Jenkins. As Sudharsan explained, the steps are:
Go to Manage Jenkins - Configure system
Add JAVA_HOME and its path in Global Properties - Environment Variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With