Community
Participate
Working Groups
Build 2.1 M1. I have one project that I only want to compile and run with JRE 1.3.1_04 and one other project that I only want to compile and run with JRE 1.4.0_02. I cannot do this without much effort: I created a new project "Test on 1.4.0" and added C:\Java\j2sdk1.4.0_02 \jre\lib\rt.jar to that project's class path. When I run a program, I get: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object If I change the classpath to remove the rt.jar and instead add JRE_LIB AND my default JSDK to 1.4.0 (in eclipse/Preferences/Java/Installed JREs then everything works fine. Same song and dance with a project called "Test on 1.3.1" This is obviously no good since it forces me switch the default JRE to get a given project working. (I am running e on top of 1.4.1_02) Thank you, Gary
The JRE_LIB variable is a global variable of the workspace, it is bound to the default JRE (checked JRE in Installed JRE preference page). In 2.0, we added a new concept which can address your issue: a classpath container. A classpath container can be used to denote a set of entries (e.g. multiple JARs) and can have a custom value for each project. JRE containers are provided, you simply need to use them on your project build path, instead of using JRE_LIB variable entries. You will find containers under the library pane of the Java build path preference page, press [Advandced], then select option "Add Container" --> JRE System, you can then select which flavor you want to use (Default, or a custom one). Is it ok to close?
Closing, please reopen if necessary.
Closing
Dup
*** This bug has been marked as a duplicate of 22754 ***
Thank you for the tip! That did it. IMHO, this was not clear at all from the UI. Please consider changing this bug report to UI or docs such that e points out how to do this task. I, of course, have never looked at the e docs so perhaps the UI could be improved. Please consider: Yes, this feature is generally speaking in the exact place I would look for it: in the Properties dialog of the Project I am working on under "Java Build Path", so far so good. The problem comes when I see THREE buttons called "Add xxx" that could all do the job that I want. After all, is it not a sensible thing to click the "Add External Jars..." button and then add the rt.jar file from a given JSDK? When I do that and I get a ... Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ... I get confused! How do I know that the solution is to add a "Container" under "Advanced..."? From a UI stand point, I think that the feature to use "Properties/Java Build Path/Advanced/click radio/Choose drop down/click ok button/choose JDSK in list box" to way too DEEP: 7 steps! Let be fair and start at "Java Build Path": 5 steps. Suggestion: I would like the e team to consider the following. Make the "Advanced" dialog better by adding radio buttons for "Add JRE System Library" and whatever else comes with e out of the box. Then under the radio button for "Add JRE System Library", you can have the drop down list of JREs. Much more compact, less UI steps in fewer UI components: Example "improved" Advanced dialog: o Create New Class Folder o Add Existing New Class Folder o Add JRE System Library [ListBox] "Add..." button (other choices?) o Add Container... [ListBox] Now I have access to the feature, right THERE in THAT dialog. Pow. I can SEE it. When I first opened that dialog, the list box was disabled, which grayed out the text and made it hard to notice that the feature was there. I did not. If adding a JRE lib with add external Jar is not how to do that, then do not let me do it. That is what really makes things confusing! Thank you for considering this, Gary