4

I am trying to perform a build on Eclipse Kepler but when I do so I get the following error javac: target release 1.6 conflicts with default source release 1.7

I have changed the Java Compiler to use 1.6 but this warned me that the default JRE was 1.7. I then went to Installed JREs removed 1.7 and created a new one for 1.6.

This still gives the sames error. I also saw something about adding -vm and the java path to eclipse.ini but this didnt help either.

Does anyone know what to do?

Clinton Green
  • 9,697
  • 21
  • 68
  • 103
  • What is the default Java on your machine? In the project you are trying to build, what is the Java level specified for the compiler? – mikemil Feb 05 '14 at 03:43
  • Default Java on the machine is java-1.6.0-openjdk. In the Eclipse/compiler I specified the same (1.6) but it still says the Eclipse default is 1.7. – Clinton Green Feb 05 '14 at 03:56
  • I have been running Kepler with Java 7 for Eclipse. By that I mean, you can pass the -vm parameter on the command line so that Eclipse runs with Java 7, but then in the preferences and projects you can setup the projects to compile and run Java 6 or 7. I need to get to another machine to check this because I don't have Eclipse installed on this machine. – mikemil Feb 05 '14 at 04:12
  • I realize this link is for Indigo but the content should be the same - see the -vm command line parm. You can run Eclipse on Java7 and still have your projects setup to use Java 6. http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html Hope this helps... – mikemil Feb 05 '14 at 04:56
  • @mikemil ignore last comment please. So i ran it using ./eclipse -vm /usr/lib/jvm/java-1.6.0-openjdk. This path is correct but I got back the following: A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/lib/jvm/java-1.6.0-openjdk/default.ee /usr/lib/jvm/java-1.6.0-openjdk/java /usr/lib/jvm/java-1.6.0-openjdk/libjvm.so – Clinton Green Feb 09 '14 at 21:37
  • @mikemil I got it to work by adding /bin to the path. Trouble is it still defaults to Java 1.7 leading the build to fail again. Any ideas? – Clinton Green Feb 09 '14 at 21:51
  • Do you have both 1.6 ad 1.7 installed on that box? – mikemil Feb 10 '14 at 02:00
  • I think so, I installed 1.6 but I think 1.7 was on it by default. – Clinton Green Feb 10 '14 at 02:05
  • Besides the Installed JREs, check the Preferences->Java->Compiler page to make sure it is setup to compile with 1.6 not 1.7. – mikemil Feb 10 '14 at 05:15

1 Answers1

2

You may want to check the project or workspace's compiler settings and verify that the Java source and target versions are the same:

  1. Right click the project in the package explorer and select 'properties'
  2. Select "Java Compiler" in the left pane.
  3. If "Enable project specific settings" is not set, then click on "Configure Workspace Settings..."
  4. Verify that the source and target are 1.6 if that's what you intend to use

Here's a link to a similar error when using javac from the commandline: Can we use jdk7 javac to compile code with java7 features into java6 bytecode

Community
  • 1
  • 1
Jay
  • 271
  • 2
  • 6