Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369230

Summary: java.home derives from Eclipse launch, not eclipse preferences
Product: z_Archived Reporter: benson margulies <bimargulies>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: igor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description benson margulies CLA 2012-01-20 09:04:56 EST
Build Identifier: 20110916-0149

In general, in Eclipse builds, the JRE used to launch eclipse itself is completely over-riden by the Java preferences dialog. This is not true for M2E, and deserves some prominent documentation -- since I doubt that there's a way to make it work differently.

In particular, there's a very common POM idiom for using tools.jar: ${java.home}/../lib/tools.jar. This requires java.home to point to a JDK (well, the JRE inside of a JDK). By default, on Windows, people launching Eclipse end up launching it with a plain old JRE, and there's no tools.jar, and so Maven fails to find this dependency.

The fix is to add

-vm
pathname/of/jdk/javaw.exe

to config.ini. 

I can't see how M2E could make this problem go away, since java.home is controlled by the JVM itself, and trying to reset it to match the eclipse preference would be a recipe for other even more mysterious problems.

Someone could, I suppose, try to write code to detect system dependency errors and warn of this, but I suspect that the best of the available alternatives is to write this up really clearly on the website and hope that people find it with Google.
 

Reproducible: Always

Steps to Reproduce:
1. import a project with a system dependency built off of ${java.home}
2. observe errors.
Comment 1 Igor Fedorenko CLA 2012-01-20 09:28:00 EST
Unlike Eclipse, Maven does not have the notion of "target JVM", so <systemPath>${java.home}/...</systemPath> really denotes a path relative to the jvm used to execute maven, which is eclipse vm in case of embedded maven runtime.
Comment 2 benson margulies CLA 2012-01-20 10:08:43 EST
Igor,

I understand and agree. The purpose of this JIRA was to write this all up including the common case where it causes trouble, primarily in the hopes of documentation.
Comment 3 Igor Fedorenko CLA 2013-09-29 10:00:26 EDT
As per last comment, this is open for future reference, but WONTFIX otherwise.
Comment 4 Igor Fedorenko CLA 2014-06-12 20:22:08 EDT

*** This bug has been marked as a duplicate of bug 432992 ***
Comment 5 Denis Roy CLA 2021-04-19 13:27:01 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/