Search code examples
javaeclipsejava-8java-6

Stop Eclipse updates on classpath and settings


I upgraded to the latest Eclipse Mars.2 Release (4.5.2) and there is one issue that is driving me crazy.

Every time I refresh a project JDK version 8 is added here:

  • .classpath, this line changes:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_72"/>

  • .settings/org.eclipse.jdt.core.prefs, this line changes:

org.eclipse.jdt.core.compiler.compliance=1.8

My project has been using JDK 6 for years. I have installed JDK 6 and 8 for testing purposes.

No matter if I change the project settings manually, every time I refresh the project Eclipse automatically sets version 8.


Even if I disable Enable project specific settings, when I refresh the project, that option is re enabled and the file .settings/org.eclipse.jdt.core.prefs is created with this content:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.compliance=1.8

Also, in Global Preferences > Java > Compiler I set 1.6 and in Installed JREs jdk1.6.0_43 is set as default.

This started happening after I upgrade Eclipse, so it is surely a bug. However, I would like to know if there is any workaround.


Other things I tried and did not work:

  • Cleaning the project
  • Starting Eclipse with eclipse -clean

Solution

  • It was a bug but not from Eclipse, from the Gradle plugin: Buildship 1.0.9.

    In case anyone has the same issue, I modified .settings/gradle.prefs and set the value for connection_java_home:

    {
      "1.0": {
        "project_path": ":",
        ...
        "connection_java_home": "C:\\Program Files\\Java\\jdk1.6.0_43",
        ...
      }
    }
    

    Now, when I refreshed the project, only .classpath was modified but with this value:

    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/
        org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_43"/>
    

    As @dit suggested, another option is to add the file gradle.properties to the project, including:

    org.gradle.java.home=C:\\Program Files\\Java\\jdk1.6.0_43