1

I have maven updated it and refreshed the project but the jdk in use is still 1.8, why?

enter image description here

lily
  • 83
  • 1
  • 10

2 Answers2

1

To clarify the answer given by Rohi-

JDK 1.7 version in your pom.xml just tells your maven compiler that you want your code and compiled classes to be compatible with JDK 1.7. What I mean by that is if you had used any feature like Lambdas in your code which is specific to JDK 1.8 or above, it would give you a compilation error since maven compiler believes that you are writing for JDK 1.7.

In you case, your eclipse/project/maven compiler is configured for using JDK 1.8, you are seeing JDK 1.8 in your library. Although, because you set the maven compiler's compliance to JDK 1.7, you won't be able to use features of JDK 1.8 even though you have that in your library.

You should change your default workspace JDK to 1.7 if you want to have that in your library.

Look here for more details and look here to compile your project using different JDK without changing the default workspace JRE.

Community
  • 1
  • 1
Mukul Bansal
  • 878
  • 8
  • 10
0

The compiled output of maven will be jdk7 as you've set. What you're looking is the JRE version your IDE is using as configured in the project properties in eclipse. You should download JDK7 and set it in the configuration inside Eclipse: Preferences -> Java -> Installed JRE

and select the java library you want to use.

Rohi
  • 385
  • 6
  • 22
  • I'm a bit confused. So there are two cases: 1) the jdk version used by eclipse itself 2) the jdk used by the project. `Preferences -> Java -> Installed JRE` is for case 1 or 2? – lily Dec 26 '16 at 12:22
  • case 1 is not relevant to any of your projects :) case 2 solves the issue of seeing jre1.8 in the libraries view (as in your screenshot). Eclipse load jdk1.8, but you can still use it to compile to jdk7 bytecode. Also understand that the maven compiler plugin is used by maven to compile, but not by eclipse who has its own internal compiler (unless you run maven build from eclipse itself). So you should set in the project settings also the target JDK. See also this answer http://stackoverflow.com/questions/2540548/how-do-i-get-eclipse-to-use-a-different-compiler-version-for-java – Rohi Dec 26 '16 at 14:59