| Summary: | Ant: using Windows, "Run in same JRE as workspace" is not a sane default | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Sven Köhler <sven.koehler> | ||||
| Component: | Ant | Assignee: | Michael Rennie <Michael_Rennie> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | gro.espilce, Michael_Rennie | ||||
| Version: | 3.6.1 | ||||||
| Target Milestone: | 3.7 M6 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Sven Köhler
(In reply to comment #0) > Taking a closer look at created ant run configuration, it says "Run in same JRE > as workspace" - which of course typically refers to a real JRE, without > javac.exe, tools.jar, or javadoc.exe. Eclipse has no way of choosing a JRE over a JDK from Eclipses' POV they are one in the same. > As you can imagine, this is really disturbing. This happens with any build.xml > you're trying to run. If you have both of them installed, the JDK and the JRE, why can you not simply choose the one you want when you are creating your launch configuration? The default selection is "run in separate VM", so you can choose a different one right then. The other option is that you could choose the installed JDK as the workspace default JRE and then all newly created launch configurations would automatically use the JDK. (In reply to comment #1) > > As you can imagine, this is really disturbing. This happens with any build.xml > > you're trying to run. > > If you have both of them installed, the JDK and the JRE, why can you not simply > choose the one you want when you are creating your launch configuration? Assume, that I'm using the simpliest way to start ant builds possible. I right click on a build.xml and select "Run As -> Ant build" or I drag&drop the build.xml to the Ant View and double click a target. For me, this creates a launch configuration where "Run in the same JRE as the workspace" is checked. Of course, I can change this single launch configuration. I know that. However, I do not think that "Run in the same JRE as the workspace" is a good default. > The default selection is "run in separate VM", so you can choose a different > one right then. The other option is that you could choose the installed JDK as > the workspace default JRE and then all newly created launch configurations > would automatically use the JDK. I just double checked, but for any newly created launch configuration, the item "Run in the same JRE as the workspace" is checked and not the "Seperate JRE". Again, please understand that this is a complaint about how Eclipse behaves for most users out there. And I assume, that most people don't configure their Eclipse to start with a JDK - instead, they install the JDK, download Eclipse, and by default it uses the default JRE, AFAIK. Am I wrong about any of that? (In reply to comment #1) > The default selection is "run in separate VM" I think, you might not be quite right about that. Can you take a look at the code, whether this is actually the default? Of my last 15 attempts of creating new Ant launch configuration, I have seen both: 1) new configurations which have "same JRE as workspace" 2) new configurations which have "seperate JRE" I think, there is some "remember last thing" logic implemented somewhere. However, it is confusing. I cannot find out, when Eclipse goes for (1) or when it goes for (2). Right now, I get the described behaviour again: even after deleting all ant-related launch configurations, the result of double clicking a target in the Ant view is a launch configuration with "same JRE as worksapace". I also wasn't able to find any possibility to change Eclipse's behaviour in the preferences. (In reply to comment #2) > Assume, that I'm using the simpliest way to start ant builds possible. I right > click on a build.xml and select "Run As -> Ant build" or I drag&drop the > build.xml to the Ant View and double click a target. > > For me, this creates a launch configuration where "Run in the same JRE as the > workspace" is checked. Of course, I can change this single launch > configuration. I know that. However, I do not think that "Run in the same JRE > as the workspace" is a good default. Right, we did introduce a regression for that option, which was fixed in bug 308645. So the default (again) for Eclipse builds >= 3.6M7 is the separate VM option. > instead, they install the JDK, download Eclipse, > and by default it uses the default JRE, AFAIK. This is correct. Unfortunately the only way to use anything other than the default JRE is to configure Eclipse manually, using the Installed JREs page as I mentioned or to edit the launch configuration. (In reply to comment #4) > (In reply to comment #2) > > Assume, that I'm using the simpliest way to start ant builds possible. I right > > click on a build.xml and select "Run As -> Ant build" or I drag&drop the > > build.xml to the Ant View and double click a target. > > > > For me, this creates a launch configuration where "Run in the same JRE as the > > workspace" is checked. Of course, I can change this single launch > > configuration. I know that. However, I do not think that "Run in the same JRE > > as the workspace" is a good default. > > Right, we did introduce a regression for that option, which was fixed in bug > 308645. So the default (again) for Eclipse builds >= 3.6M7 is the separate VM > option. Interesting. I'm using Eclipse SDK, Version: 3.6.1, Build id: M20100909-0800. Was the bug re-introduced? (In reply to comment #5) > Interesting. I'm using Eclipse SDK, Version: 3.6.1, Build id: M20100909-0800. > Was the bug re-introduced? I just tried on 3.6.1 (M20101117-1123) and the 'separate VM' option is selected when I create a new configuration from either the launch dialog, editor or Ant view. I did find something curious though: When you open the dialog and create a new configuration the JRE selected in the combo is the workspace default JRE. Whereas when you create a configuration from the editor or the Ant view, the JRE from the build path of the enclosing project will be selected in the combo: unless there is no JRE on the build path, then the option to use the same JRE as the workspace in selected! I would assume that creating the configuration would work the same no matter where it is invoked (dialog, editor, view). Is this the behavior you are seeing Sven? (In reply to comment #7) > I did find something curious though: > > When you open the dialog and create a new configuration the JRE selected in the > combo is the workspace default JRE. In the "External Tools configuration" dialog, when I hit the new Button, it creates a configuration which has the "seperate JRE" is selected - I don't know when. It's completely undeterministic from my point of view. > Whereas when you create a configuration > from the editor or the Ant view, the JRE from the build path of the enclosing > project will be selected in the combo: unless there is no JRE on the build > path, then the option to use the same JRE as the workspace in selected! > > I would assume that creating the configuration would work the same no matter > where it is invoked (dialog, editor, view). > > Is this the behavior you are seeing Sven? Yes, I think so. I should have noticed, that the project I'm trying to compile does not have a JRE or JDK in its build path. I'm sorry for not telling you. It's a project, that implemenents a small replacement for the class library of a JDK. So it contains an implementation of java.lang.Object and such things, and not having a JDK in the classpath is correct AFAIK. Also, other projects exists in my workspace, that have this replacement for rt.jar in the classpath, instead of a full JRE/JDK. So the logic will fails for those projects too. I'm not sure whether Eclipse can do something sensible here. Three things come to my mind: Instead of the workspace JRE, chose 1) the default JRE as configured in the "Installed JREs" preference page 2) use the execution environment (J2SE-x,y) that corresponds to the maximum of class/source version as configured on the projects "Java compiler" preference page. 3) implement a dialog that says "chose a JDK, because I can't computer the right one" instead of silently chosing the workspace JRE (In reply to comment #8) > > I'm not sure whether Eclipse can do something sensible here. Three things come > to my mind: Instead of the workspace JRE, chose > 1) the default JRE as configured in the "Installed JREs" preference page I was thinking this would be the best option. We should make the JRE selection consistent so users know that they will *always* get the 'separate JRE' option selected with an understandable choice in JRE for it, for new launch configurations. Created attachment 188011 [details]
proposed fix
The patch tries to resolve the JRE from the project, and failing that chooses the workspace default VM
applied to HEAD Can we add an option to always use "Run in same JRE as workspace", I move from project to project quiet often and the `build.xml` scripts fail because they leverage Eclipse specific variables that are ONLY available in "Run in same JRE as workspace" mode. So the original default to "Run in same JRE as workspace" was the correct option. (In reply to Daniel Sokolowski from comment #12) > Can we add an option to always use "Run in same JRE as workspace", I move > from project to project quiet often and the `build.xml` scripts fail because > they leverage Eclipse specific variables that are ONLY available in "Run in > same JRE as workspace" mode. > > So the original default to "Run in same JRE as workspace" was the correct > option. Disregard the above - digging deeper in the settings I found: http://www.codejava.net/images/articles/ides/eclipse/antjre/Ant%20preferences.png |