Indicating to maven what java installation to use

59 views
Skip to first unread message

erle mantos

unread,
Sep 11, 2007, 7:17:03 AM9/11/07
to q4e...@googlegroups.com
Hi Guys,..

I've been having a problem where the java installation that the maven
embedder is going
to use to execute goals is the JRE and not the JDK. See the screenshot
for the error.

To reproduce, delete your "runtime-EclipseApplication" directory
first, checked out the maven-trunk
(http://svn.apache.org/repos/asf/maven/components/trunk ),
use the "import maven 2" function to import it into the workspace,
then run the process-test-resources goal on the maven-lifecycle project
by using:

right click on project > run as > Open run dialog > Maven 2 >

then create a new maven 2 launch configuration, the project should be
maven-lifecycle,
the goal should be "process-test-resources", then click "Run" ..

Based on the screenshot, the java installation that the maven embedder used
is the JRE which is wrong. The problem is, I don't know how to
indicate to the maven
embedder to use the JDK.

I have already indicated in Window > Preferences > Java > Installed JREs to use
the JDK installation, also in Window > Preferences > Plugin
Development > Target Platform > Environment > Java Runtime Environment
> Target JRE. I also have made sure that
the JDK /bin path is first in the PATH variable, still, the problem persist.

Any ideas would be greatly appreciated ....


Cheers,

Erle
--
A world without C++ is chaos.

Screenshot.JPG

Abel Muiño

unread,
Sep 11, 2007, 12:39:42 PM9/11/07
to q4e...@googlegroups.com
You should launch eclipse with the JDK. By default, it uses the installed JRE.

To do so, use the option -vm pointing to your javaw.exe. For example:
  eclipse -vm c:\JDK\bin\javaw.exe

Hope this helps!

Carlos Sanchez

unread,
Sep 11, 2007, 12:58:04 PM9/11/07
to q4e...@googlegroups.com
the compiler plugin by default doesn't fork so it will use the java
use by Eclipse.
What I wonder is how the JDT guys let the user choose the Java
installation, do they fork? or do they add the tools.jar to the
compilation classpath?


--
I could give you my word as a Spaniard.
No good. I've known too many Spaniards.
-- The Princess Bride

Abel Muiño Vizcaino

unread,
Sep 11, 2007, 4:20:15 PM9/11/07
to q4e...@googlegroups.com
As far as I know, JDT uses the eclipse compiler and does not depend on tools.jar.

The compiler is even available for use with maven: http://maven.apache.org/plugins/maven-compiler-plugin/non-javac-compilers.html

BTW, could we somehow pass the compiler configuration for using a JDK () when running maven goals? I know it looks like a hack, but I think it would look better than telling the users to change their eclipse command line arguments. This might not be enough is other plugins/project dependencies depend on tools.jar, though.

Carlos Sanchez

unread,
Sep 11, 2007, 5:02:49 PM9/11/07
to q4e...@googlegroups.com
the eclipse compiler support is not good at all (yet), it could be a
future improvement though

erle mantos

unread,
Sep 11, 2007, 11:35:06 PM9/11/07
to q4e...@googlegroups.com
Maybe there is a way we can indicate in the manifest file that we need a
JDK and not a JRE .. I'll have to do a bit of testing on that.

xgene...@gmail.com

unread,
Sep 19, 2007, 7:31:28 AM9/19/07
to Q for Eclipse developers list
This does not seem to work launching eclipse with eclipse -vm c:\JDK
\bin\javaw.exe.
Is there any configuration i need to do with system environment?


On Sep 12, 12:39 am, "Abel Muiño" <amu...@gmail.com> wrote:
> You should launch eclipse with the JDK. By default, it uses the installed
> JRE.
>
> To do so, use the option -vm pointing to your javaw.exe. For example:
> eclipse -vm c:\JDK\bin\javaw.exe
>
> Hope this helps!
>

Genesis Deiparine

unread,
Sep 19, 2007, 7:36:39 AM9/19/07
to Q for Eclipse developers list
I see my bad... it's now launching it ... :)


This does not seem to work launching eclipse with eclipse -vm c:\JDK
\bin\javaw.exe.
Is there any configuration i need to do with system environment?


On Sep 12, 12:39 am, "Abel Muiño" <amu...@gmail.com> wrote:
> You should launch eclipse with the JDK. By default, it uses the installed
> JRE.
>
> To do so, use the option -vm pointing to your javaw.exe. For example:
>   eclipse -vm c:\JDK\bin\javaw.exe
>
> Hope this helps!
>
> On 9/11/07, erle mantos < eman...@gmail.com> wrote:
>
>
>
> > Hi Guys,..
>
> > I've been having a problem where the java installation that the maven
> > embedder is going
> > to use to execute goals is the JRE and not the JDK. See the screenshot
> > for the error.
>
> > To reproduce, delete your "runtime-EclipseApplication" directory
> > first, checked out the maven-trunk

ossi

unread,
Sep 21, 2007, 4:58:02 AM9/21/07
to Q for Eclipse developers list
hallo

i posted the same problem in the users list too:
http://groups.google.com/group/q4e-users/browse_thread/thread/6770ba1c0f8cb65a/45ff0f435d568b1d#45ff0f435d568b1d

there is one big thing in this: eclipse only needs a JRE to run. one
should not need to start eclipse with a full JDK.

in the eclipse preferences one then configures a default jre (actually
you will configure jdk's in here) and maybe some additionals ones. so
for me: i got three jdk configured: 1.4, 1.5, 1.6, 1.4 as default. yet
i start eclipse with jre 1.6

my maven-ized projects inherit the default 1.4 jdk. also the 1.4
system classes are added to the classpath (tools.jar) but when i run
goals via q4e the missing tools jars is reported. which is true since
i started eclipse with jre 1.6, yet i want to use a jdk 1.4 to compile
things. so q4e should use the jdk configured for the project to
compile things. it must not use the jre that was used to start
eclipse. actually it is quite normal to use a different one. java 1.6
is faster, looks better for rcp things. but yet projects really need
to compile withe the proper jdk if one does not want to run into
minor, major class version trouble or serialUid weirdness.

i dont know how eclipse does this with standard projects, obviously
there must some way, otherwise i would have never been able to compile
anything :)

if yo only need to make things work: copy the 1.6 jdk into ECLIPSE/jre
folder. that allows q4e to work but it then ignores the project
settings for the jdk.


Carlos Sanchez

unread,
Sep 21, 2007, 10:34:28 AM9/21/07
to q4e...@googlegroups.com
well, this is tricky, because if we honor the eclipse settings then if
you run maven from the command line you are going to get different
results. If you configure a specific JDK in the pom as in
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
then it will be used both in Eclipse and in the command line.

ossi

unread,
Sep 26, 2007, 5:52:39 AM9/26/07
to Q for Eclipse developers list
hallo

indeed the results will differ. but to be honest that is the
responsibility of the developer to take care command line build match
the eclipse builds.

but the other way around should be working too: if my command line
environment is set to jdk 1.4 and i run eclipse with 1.6 (speed, look,
plugins requirements) and configure the project to use 1.4 then i must
rely on eclipse it is actually doing what it is told.

so in migration status (some java 1.4 projects, some 1.5) both jdk
will be around, and i would create some mvn4 script to use jdk 1.4 and
some mvn5 script to use jdk 1.5 on the command line. in eclipse the
comfort will be to define the right jdk.

the jdk is not a setting that can be ignored. even if i can use 1.6 to
create 1.4 classes, some jdbc interfaces have changed. if i implement
one of those some methods are suddenly missing. so not everything will
compile with a newer jdk.

its a must have from my point of view :)

regards
ossi

On 21 Sep., 16:34, "Carlos Sanchez" <car...@apache.org> wrote:
> well, this is tricky, because if we honor the eclipse settings then if
> you run maven from the command line you are going to get different

> results. If you configure a specific JDK in the pom as inhttp://maven.apache.org/plugins/maven-compiler-plugin/examples/compil...


> then it will be used both in Eclipse and in the command line.
>

> On 9/21/07, ossi <knud...@gmail.com> wrote:
>
>
>
>
>
> > hallo
>
> > i posted the same problem in the users list too:

> >http://groups.google.com/group/q4e-users/browse_thread/thread/6770ba1...

Abel Muiño

unread,
Sep 26, 2007, 6:19:44 AM9/26/07
to q4e...@googlegroups.com
Hello Ossi,

The ability to automatically use the JDK library specified in the project preferences would be great to have. Could you open an enhancement request on the issue tracker summaryzing what's been discussed so far?

Until that feature gets implemented, you can use the workaround described by Carlos. I think it makes a lot of sense to specify in the POM the JDK you want to use to build your project, if you have strict requirements.

Specifying the JDK in a script works, but it does not fit well with Maven's ideal of providing a single source of information for building a project (the pom.xml).

Abel.

Carlos Sanchez

unread,
Sep 26, 2007, 10:37:48 AM9/26/07
to q4e...@googlegroups.com
i agree with Abel, if you have a strict requirement of compiler to use
then you should configure it in the pom, instead than in an script. If
not your build is not going to be reproducible
Reply all
Reply to author
Forward
0 new messages