Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: JRE System Library in Java Build Path reset

For developing a JavaFX application I'm using a 4.3.1 snapshot of eclipse together with JDK 8 build b116. In my workspace projects the JRE library inclusion in the build path get resetted back to Java 1.4 all the time:

the problem

Unfortunately, this can only be fixed temporary (until the next eclipse restart):

the temporary solution

In the build section of my pom files I have:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <debug>true</debug>
        <debuglevel>source,lines</debuglevel>
    </configuration>
</plugin>

I'd appreciate a less volatile solution.

[UPDATE] The issue seems to be fixed with the current versions of

  • Java 8 (1.8.0-ea-b121),
  • Maven (3.1.1/1.5.0.20131218-0705),
  • m2e (1.5.0.20131218-1208) together with the
  • JDT beta patch [Update site].
like image 236
Jens Piegsa Avatar asked Nov 22 '13 13:11

Jens Piegsa


People also ask

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 .

Where is Eclipse build path stored?

The build path is stored in a file named . classpath in the project's root directory.


1 Answers

The maven eclipse plugin (m2e) selects a java execution environment depending on the <source> and <target> properties for the maven compiler plugin.

The problem is that there is neither a 1.8 execution environment available in Kepler nor the m2e maven compiler connector can map it yet.

Thus I see two solutions until it is supported in Kepler and m2e:

  1. Let maven change the environment to 1.4 and map your 1.8 JDK to the execution environment J2SE-1.4. Then your project will use the correct JDK. But then all projects that depend on 1.4 will use the 1.8 JDK of course.

  2. Use the pluginManagenent to turn off the maven-compiler-plugin lifecycle handling. This should prevent the m2e plugin from updating the execution environment and you can set it manually.

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                     <lifecycleMappingMetadata>
                           <pluginExecutions>
                                 <pluginExecution>
                                     <pluginExecutionFilter>
                                           <groupId>org.apache.maven.plugins</groupId>
                                           <artifactId>maven-compiler-plugin</artifactId>
                                           <versionRange>[1.0.0,)</versionRange>
                                         <goals>
                                             <goal>compile</goal>
                                         </goals>
                                     </pluginExecutionFilter>
                                     <action>
                                          <ignore />
                                     </action>
                                 </pluginExecution>
                           </pluginExecutions>
                     </lifecycleMappingMetadata>
               </configuration>
           </plugin>
        </plugins>
    </pluginManagement>
    
like image 130
René Link Avatar answered Sep 21 '22 08:09

René Link