Different JVM for running Eclipse, Ant build

Eclipse has multiple relation with the JVM : there is the JVM used to run Eclipse ; the JVM used by Eclipse to compile and build your projects ; Ant’s build file can fork and use another JVM too.

  • The most important and the easier : the JVM used for your projects. You can see them in Window / Preference ... : Java / Installed JREs. There you can add a new one or check the default one. Could it be override by each project ? (I didn’t find where.)
    The WebTools Platform let you choose one of those JVM to run your application server (ex: Tomcat.)
  • The JVM used to run Eclipse is harder to configure ! You can get general info in help.eclipse.org.
    To know wich JVM is used go to Help / About and click Configuration Details. By default, Eclipse uses the first JVM it finds in the PATH (not JAVA_HOME.)
    So, you have to put a -vm /path_to/java argument to Eclipse. If you use MacOSX … Ctrl-click your Eclipse icon and Show Package Content ; open Info.plist and in the Eclipse node add two sibling -vm and /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java (put them at the end and continue the numbering.)
    Note the info.plist is for Eclipse arguments only, for the jvm they can be put in MacOSX/eclipse.ini (still in the Package Content.)
  • Ant too can launch a task with a different JVM : look at the java task. You can use the jvm attribute :
    <target name="start.tomcat">
        <java classname="org.apache.catalina.startup.Bootstrap"
                jvm="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java"  
                fork="yes">
            <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
            <arg value="start"/>
        </java>
    </target>

One Response to Different JVM for running Eclipse, Ant build

  1. macgrunigan says:

    Hi,

    You can choose your JVM for your project in Eclipse in the project properties window. Select “Java build path” and the “Libraries”. At the botton you should see something like JRE System Library. Remove it and push “Add library”. There you have to choose JRE System Library and, finally, there you can choose the jvm for your project. In the same window you have mor options to choose the compiler style (1.2, 1.3, 1.4, etc) and other stuff. Play with it.

    ¡Hasta luego!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: