Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse JRE System Library [J2SE-1.5]

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?

like image 680
Sinisha Mihajlovski Avatar asked Mar 29 '12 13:03

Sinisha Mihajlovski


People also ask

How do I fix JRE system library in Eclipse?

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.

Where is JRE system library located?

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 .

What is JRE system library in Java?

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.


2 Answers

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> 
like image 130
artbristol Avatar answered Oct 05 '22 17:10

artbristol


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> 
like image 44
paulsm4 Avatar answered Oct 05 '22 15:10

paulsm4