views:

640

answers:

1

Problem overview:

When using Eclipse Ganymede with the Web Tools Platform the project gets dependent on the exact JRE name I use. The name might be different on other developers machines, how is this problem best solved so that many developers may work together on the project?

Detailed problem description:

I'm using Eclipse Ganymede and Web Tools Platform (as it's part of Eclipse IDE for Java EE Developers) and I have created a Dynamic Web Project.

I have a single JRE installed, the Sun JRE for Java SE 6. In Eclipse I can choose: Window / Preferences / Java / Installed JREs. And I can see a list of JRE's, each row has Name, Location and Type columns.

I only have one entry in the list, it has: Name=java-6-sun-1.6.0.07 Location=/usr/lib/jvm/java-6-sun-1.6.0.07 Type=Standard VM.

The problem is that the name of my JRE is specified in two Eclipse project meta-data files, they are .classpath and .settings/org.eclipse.jst.common.project.facet.core.prefs.

I want to check my project into version control for other developers to check out and work on, but I don't think that I can be sure that they have a JRE with the same exact name as I do.

Contents of the offending files:

.classpath: (The second to last classpathentry is the offending tag.)

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src/main/java"/>
        <classpathentry kind="src" path="src/main/resources"/>
    <classpathentry kind="src" path="src/test/java"/>
    <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=*">
     <attributes>
      <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
     </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-sun-1.6.0.07"/>
    <classpathentry kind="output" path="target/eclipse/classes"/>
</classpath>

.settings/org.eclipse.jst.common.project.facet.core.prefs:

#Mon Feb 02 13:29:53 CET 2009
classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:java-6-sun-1.6.0.07/owners=jst.java\:6.0
eclipse.preferences.version=1


What's the best way to check in this project and let other developers check it out and run/change it?

+1  A: 

Select the execution environment instead of the JRE to use. To do so, got to your project -> Properties -> Java Build Path -> Libraries. Select the "JRE System Library" element, click "Edit..." and select the Execution Environment of your choice (probably "JavaSE-1.6" for your example).

The .classpath file will then contain an entry like this:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
Joachim Sauer
Ah, looks promising. I'll check as soon as I'm back at work. However if that doesn't work for .settings/org.eclipse.jst.common.project.facet.core.prefs too I'm still in a pickle. I cross my fingers! :-)
DeletedAccount
Worked nicely! However I had to *manually* replace java-6-sun-1.6.0.07 with JavaSE-1.6 in the .settings/org.eclipse.jst.common.project.facet.core.prefs file by editing it in a text editor (good to know for anyone trying to do this using the GUI). Anyway, excellent answer!
DeletedAccount
https://bugs.eclipse.org/298712 details a limitation to this approach to keep in mind.
nitind