So, this isn't about running java code from within eclipse but executing the java command from maven inside eclipse (outside eclipse it works just fine).
To be concrete:
we have a .cmd file we execute from within maven, the relevant parts of it:
java -classpath (the classpath) com.bea.wls.ejbgen.EJBGen (and some other stuff)
When run from the command line (mvn clean install), we do get this output:
EJBGen WebLogic Server 12.1.3.0.0 Wed May 21 18:53:34 PDT 2014 1604337
Creating my\package\ejb\Local.java
Creating my\package\ejb\WebserviceLocal.java
Creating my\package\ejb\ServiceLocal.java
Creating my\package\ejb\LocalHome.java
Creating my\package\ejb\WebserviceLocalHome.java
Creating my\package\ejb\ServiceLocalHome.java
all is well,
however when executed from within eclipse:
EJBGen isn't supported by JDK version higher than 1.7
Now, how does the console/m2e run chooses which java binary to use?
- Both jdk/jre 8 and jdk 7 are installed on my system.
- I use jdk 8 as runtime for eclipse (inside the eclipse.ini)(it's neon, it won't run if I try to use 7) and my 'installed jre' is set to (jdk) 7 (see first screenshot below)
- the JAVA_HOME variable is set to 7 (if I run java -version it outputs 7)
- I restarted eclipse multiple times
- The execution environment of the m2e run configuration is set to jdk7 also (second screenshot)
Any help/pointers greatly appreciated!!!
S.
edit:
the configuration of (indeed) the exec-maven-plugin plugin:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>runEJBGen</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>runEJBGen.cmd</executable>
<!-- optional -->
<workingDirectory>${project.basedir}\src\main\java</workingDirectory>
</configuration>
</plugin>
we use this mechanism (and not the java variant) because of other - project specific - reasons...
edit 2: compiler options of pom.xml
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

