Mauricio
Mauricio

Reputation: 206

Jenkins: Fatal error compiling: error: release version 11 not supported - But Java and Maven point correctly the version

I'm running a Jenkins server on Centos. I was trying to build a small maven project that uses Java 11. Since the machine had OpenJDK 11 already installed, I thought it was gonna be easy.

I wrote the following script:

pipeline {
    agent any
    tools {
        maven "Maven3.6.3"
    }
    stages {
        stage('Build') {
            steps {
                git branch: 'XXX',
                credentialsId: 'sshcredential',
                url: 'giturl'

                sh "ls -lat"
                sh "java -version"
                sh "mvn -v"
                sh "echo $JAVA_HOME"
                sh "mvn clean install -e"
            }
        }
    }
}

It gives the following error:

Fatal error compiling: error: release version 11 not supported

Now I think I understand what is telling me, but I don't know why isn't using the proper java version. I added a few commands to see what they would print:

sh "java -version" prints

openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

sh "mvn -v" prints

Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.6.3
Java version: 11.0.13, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64

sh "echo $JAVA_HOME" prints

/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64

If anyone has an idea of what could be happening, I would be very thankful. I have a feeling I'm stuck on something very basic, yet I can't see it. I tried looking other answers, but nothing helped me.

Upvotes: 0

Views: 1951

Answers (1)

Mauricio
Mauricio

Reputation: 206

Turns out, the machine needed to install the development version of jdk

sudo yum install java-11-openjdk-devel

Upvotes: 2

Related Questions