Jenkins will not use Java 7 compiler

I’m working with a team on a maven project, and I set up a build job for it in Jenkins.

Recently, someone on the team added code that switches on a String. This caused the build to fail in Jenkins with the following error:

error: strings in switch are not supported in -source 1.5

So of course I realized Jenkins needs to be using Java 7, not Java 5.

First, I remoted into the server, opened a cmd, and did where java and java -version. I checked my environment variables and my path. Everything is pointing to the same Java 7 jdk directory: C:\Java\jdk1.7.0_21.

Then I checked Jenkins to see if it was configured to use the correct JDK. It is:
Jenkins JDK

In fact, that’s the only Java that the Jenkins server is set up to use, and it’s the only Java installed in the Server.

As a last resort, I installed the JDK parameter plugin into Jenkins. I then set the project to use the Java 7 parameter:

Parameter JDK

But still, I get the same error.

Am I missing something? What could be causing this? Most importantly, how can I solve it and get Jenkins to use -source 1.7 instead of -source 1.5?

  • now getting 401 unauthorized in jenkins when deploying artifact to archiva maven repo
  • Error in SonarQube when launching svn blame
  • Adding MANIFEST.MF (and 2 other file types) to .gitignore
  • Pass variable from jenkins to testng.xml
  • Jenkins jobs and GIT/maven
  • release prepare hangs at git push
  • Put current git branch to project version
  • git push fails using maven release plugin
  • One Solution collect form web for “Jenkins will not use Java 7 compiler”

    Check your pom.xml and what java version (for the source) is specified there. That could be where the source 1.5 is coming from.

    Git Baby is a git and github fan, let's start git clone.