I'm using Eclipse EE 3.7 with m2e plugin installed. I have JDK7 set in eclipse. When I import maven projects, the JRE is set to JRE System Library [J2SE-1.5]
, So i have compilation issues with java 6 related stuff. Instead I want the JRE in eclipse to be by default set to JRE System Library [J2SE-1.6]
When i try to open a new project in eclipse File -> new -> Java project on the first screen i have an option to choose JRE and the third option is Use default JRE (currently 'jdk1.7.0_03')
From this i can see that the default JRE in Eclipse is 1.7, but when i import new Maven projects, the JRE is set to 1.5 by default.
Any help, how can i do this?
Go to Window - Preference - Java - Installed JREs page to specify the location of your jre or JDK. Thanks Kane again checked Window - Preference - Java - Installed JREs->the path that referring was not correct. Now its works Fine.
In 'Java Build Path'->'Libraries' tab, you will see the 'JRE System Library' displayed as shown below. Once you will expand the JRE system library folder, you will find the .
JRE System Library is added by Eclipse IDE automatically on creating Java Projects. JRE System Library implements the Java API in Eclipse IDE. So all the predefined functions of Java, can be accessed by the Java Programs written in Eclipse IDE because of this JRE System Library.
The problem is not with Eclipse, but with the projects you're importing. m2e will set the project's JRE to match the maven project. The POM specifies the JRE version, and this is defaulted to 1.5 if not present. You need this in the POM:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
artbristol gave the correct answer (and I upvoted him).
That was in 2012. Here is an update more appropriate for today (2016, Java 8, Spring 4.x/Servlet 3.x):
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With