Change JDK used by Buildship

I have been using Buildship to compile a Gradle Java multi-project in Eclipse. Recently, a new feature was added which requires a newer version of JDK. How do I use the newer version of JDK to compile the projects?

When I run a Gradle build task in Eclipse, in the Console window I can see that it is using the older version of Java (Java Home is displayed near the top of the Console output). I see that this version of Java is also specified in the “.settings/org.eclipse.buildship.core.prefs” files stored with each project. Is there a way I can tell Buildship to use the newer version of JDK? Specifying the newer version under Java Build Path in Eclipse doesn’t fix it for Buildship. Seems that maybe Buildship is using the JDK version that was specified when I first imported the project.

Thank you for your help!


You’ll need to re-import the project to change that setting. We will remove it in Buildship 2.0

Instead of using that setting (just leave it empty on your re-import), define the in your ~/.gradle/ This will apply equally to command line builds and the IDE.

If you want to get even more correctness out of your build, I suggest letting your build find the correct javac executable for the version you want to compile against. The user guide explains it for Java 6, but it applies to any other version as well. This decouples the Java version that your build is running on from the Java version that the compiler uses.

Thank you very much, Stefan! If I am understanding you correctly, Buildship 2.0 has the capability to specify an updated JDK without the need to re-import the project?

No, Buildship 2.0 will not have the JDK option at all, since the JDK for Gradle can already be defined in ~/.gradle/

OK, got it. I assume if this value of in changes then the updated JDK will automatically be used by Gradle/Buildship 2.0 without the need to reimport?

That’s right, it will pick up the updated value.

Wonderful, thank you for your help, Stefan!