1

Using Eclipse with the m2eclipse plug-in, how do I update the pom.xml, so the “Maven->Update Project” won’t reset the project configuration back to Java 1.5? I am using Eclipse Kepler 4.3, Java 7, and the m2eclipse plug-in. I create a new Maven project with “Create a simple project (skip archetype selection)” checked and the artifactId “test”. I get the following warning.

Description Resource Path Location Type Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. test Build path JRE System Library Problem

I use the following steps the change the compiler from 1.5 to 1.7. 1. On the project, do right-click “Properties” and select the “Java build path”. 2. Go to the “Libraries” tab. 3. Remove the old JRE System Library [JavaSE-1.5]. 4. Click “Add Library…”, select “JRE System Library”, and click “Next>”. 5. Check “Execution environment” radio button and select “JavaSE 1.7 …” from the adjoining menu. 6. Click “Finish” 7. Click “OK”.

The warning disappears.

I right-click the project and select “Maven->Update Project”. I click “OK”.

The warning message returns.

My understanding is the plugin uses the pom.xml to update Eclipse’s current settings. How do I update the pom.xml, so the “Maven->Update Project” won’t reset the project configuration back to Java 1.5?

I looked at these pages, but I think the answers are obsolete. Warning - Build path specifies execution environment J2SE-1.4 What causes a new Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't? maven does not compile in java 1.6

For example, adding …

<configuration> <source>1.7</source> <target>1.7</target> </configuration>

… after the version section in the POM doesn’t fix the problem.

2 Answers 2

1

You need to use the maven compiler plugin.

<build> <plugins> <!-- Tell maven to compile using Java 1.7 --> <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> 
Sign up to request clarification or add additional context in comments.

2 Comments

I updated pom.xml to look like this.<project ...> <modelVersion>4.0.0</modelVersion> <groupId>com.aglx</groupId> <artifactId>test</artifactId> <version>0.0.1-SNAPSHOT</version> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </project>This did NOTsolve the problem.
1. You're missing the build tag around your plugins. 2. Comments are a terrible place to put code snippets.
0

You'll need to set the Maven Compiler Plugin to use a specific version

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.