Bug 208528 - Allow user to specify platform used for new projects
Allow user to specify platform used for new projects
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Platform
7.1
PC Linux
: P3 (vote)
: 7.2
Assigned To: Tomas Zezula
issues@java
:
Depends on: 212540
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-16 21:55 UTC by Geertjan Wielenga
Modified: 2012-05-25 05:47 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
patch proposal (1.31 KB, patch)
2012-05-24 00:20 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geertjan Wielenga 2012-02-16 21:55:21 UTC
It is not possible to set the default JDK. This problem comes up repeatedly in blogs, forums, twitter, and elsewhere. Would be good to have it fixed.
Comment 1 David Strupl 2012-02-17 07:13:07 UTC
Hello,

"Default JDK = The JDK you started NetBeans on". What do you mean by "setting it"? You can start NB on different JDK by using either command line switch or entry in etc/netbeans.conf.

I am closing this as invalid - if we succeed in clarifying what is exactly meant by the users, let's reopen. Until then please leave as closed. Thanks.

I am also changing the category to something more sensible ... actually category that would correspond to Java Platform manager (hopefully) but I am really not sure we want to change anything in java platform manager.

Isn't the problem in documentation/UI elements? Seems like the users might not be getting from where the default platform came from ...

Br,

David
Comment 2 David Strupl 2012-02-17 07:14:13 UTC
Or do you mean de-coupling of Default Java Platform from the "java platform you started NB on"?
Comment 3 Geertjan Wielenga 2012-02-17 07:15:52 UTC
Yes, the decoupling would be great, because right now it's not clear at all how the default JDK should be set (and its not intuitive to start the IDE with a different JDK, i.e., no GUI for setting it in the Options window), so right now this is really confusing. Reopening.
Comment 4 Petr Somol 2012-02-17 08:30:28 UTC
It is true that Default Java Platform might be confusing as of its exact role and impossibility to redefine, however, decoupling to two platforms that would be shown by default to all users has serious drawbacks from UEX point of view. I wonder what percentage of users is now confused by the current state, and what percentage of users would be confused by the existence of two variants of a default platform. I suspect these percentages would be at least similar (although I do not have any hard proof). In general, if it is not absolutely necessary, keeping a simple looking UI element simple looking tends to be preferable to put on display any new UI complexity - anything that requires additional thought about what's going on in UI from the general user.

I would be more happy if there was some way to "decouple on demand" only for those who need it.
Comment 5 Geertjan Wielenga 2012-02-17 08:36:15 UTC
The question people have is: "How do I change the default JDK?" At the very least, if I have 3 JDKs (or 2 or 5 or whatever) in the Java Platform dialog, I should be able to right-click on any of them and choose a menu item "Set as Default". 

This seems to me to be logical behavior. That's what you expect when there are multiple instances of some node and only one of them can be the default (same is true when you have multiple projects in the Projects window, you can change which one is the default project).
Comment 6 Jan Lahoda 2012-02-17 08:59:35 UTC
(In reply to comment #5)
> The question people have is: "How do I change the default JDK?" At the very
> least, if I have 3 JDKs (or 2 or 5 or whatever) in the Java Platform dialog, I
> should be able to right-click on any of them and choose a menu item "Set as
> Default". 

I guess the main question here is: And what should setting the "Default" platform do? I can imagine a lot of answers, for example it might change IDE settings and force restart (which basically matches the current concept). If that is not the correct answer then please consider the following case: I have a (J2SE) project "A", set its platform to "JDK 1.6 (Default)". Now, in Java Platform dialog, I click on "JDK 1.7" and do "Set as Default". What is the platform of project "A" now?

So, I think the behavior needs to be specified in more details that "Set as Default". (Not speaking about technical challenges of some of these decisions - to keep performance of running the project good, keeping it buildable headlessly, etc.)

I also wonder if simply changing the "(Default)" part to something of meaning "the platform NetBeans is running on" wouldn't be sufficient, possibly with some UI to change the NB runtime platform (which, however, is not that much related to java/platform, as you would want to be able to do that also for non-Java distributions). Because there really is one platform that is special: the one NB is running on.

> This seems to me to be logical behavior. That's what you expect when there are
> multiple instances of some node and only one of them can be the default (same
> is true when you have multiple projects in the Projects window, you can change
> which one is the default project).
Comment 7 Geertjan Wielenga 2012-02-17 09:08:49 UTC
The place where the default platform setting is used is when you create new Java projects. So, if I change the default platform setting, the only impact I expect that to have is that when I create the next Java project, the default platform will be used for that project. I don't expect existing Java projects to now suddenly use the new default and I don't expect the IDE's own JDK setting to change. I simply assume that if I change the default platform, all subsequent Java projects will be created to run on the new default.
Comment 8 Tomas Zezula 2012-02-17 10:08:52 UTC
The default JDK is the JDK on which the IDE is started, it can be set on command line by --jdkhome.
The "default platform" is NOT just a platform used by creation of a new project.
Default platform is somehow special and differs from other platforms.
1st) It's dynamic
2nd) It has special build-impl.xml which needs to be regenerated when you change among default and non default platform
3rd) It's easily shareable, not true for non default platform.

So changing default platform to some other platform is impossible.
Setting some flag on platform to use it as for new projects is doable.
I think that the best behavior is to use last used platform for new project creation and add combo with platforms into new project wizard.
Comment 9 Geertjan Wielenga 2012-02-17 10:30:22 UTC
"Setting some flag on platform to use it as for new projects is doable."

That's all that's being asked for. I.e., the user should be able to go to the Java Platform Manager and specify which platform should be set as the default to be used when new projects are created. 

Then, which is exactly as you suggest, there should be a combo box in the New Project wizard, where the user can select the platform they want to use -- the one that will automatically be selected would be the one set to be the default in the Java Platform Manager.
Comment 10 Tomas Zezula 2012-02-17 10:34:23 UTC
OK.
But we should not call it "Default" as it means something different in NB context as I've explained in comment # 8.
Comment 11 Geertjan Wielenga 2012-02-17 10:37:02 UTC
But the technical meaning of "Default", as you've described it, is not something the user cares about, do they? I think we should use the term in the way the end user expects to be using it, not for our internal usage of the term.
Comment 12 Geertjan Wielenga 2012-02-17 10:38:36 UTC
Well, the user cares because the default JDK is the JDK on which the IDE runs. So maybe we could call that the "IDE Platform" instead? And the "Default Platform" would be the one used as the default platform when creating new projects?
Comment 13 Tomas Zezula 2012-02-17 10:56:00 UTC
Yes, it's possible.
We need somehow distinguish the current default platform from a new default platform.
People are mostly using default platform as it builds faster (no fork) and it is easily shareable.
Renaming it may cause confusion. User will use the new default platform and share project.
The project on the new location will become broken and user will need to resolve broken platform.
Comment 14 Tomas Zezula 2012-05-15 14:42:02 UTC
From off line discussion with Jesse:
<cite>
I think it would be nice to preset the Java platform for new projects to the last-set platform, since that is commonly what you want.
</cite>

I agree with Jesse, this is probably the best solution.
Comment 15 Petr Somol 2012-05-15 14:57:39 UTC
(In reply to comment #14)
> <cite>
> I think it would be nice to preset the Java platform for new projects to the
> last-set platform, since that is commonly what you want.
> </cite>

I agree with that. Just remarking that we should not mix SE and FX; technically FX platform is a SE platform, so mixing is possible. (If the user creates a SE project with Platform1, then a FX project with DefaultFXPlatform, then a SE project again - now Platform1 should be offered to her instead of DefaultFXPlatform.)
Comment 16 Tomas Zezula 2012-05-15 15:05:56 UTC
In reply to comment #15:
Right :-)
Comment 17 Tomas Zezula 2012-05-21 13:26:00 UTC
Fixed jet-main ae0746286625
Comment 18 Quality Engineering 2012-05-22 16:35:02 UTC
Integrated into 'main-golden', will be available in build *201205220903* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ae0746286625
User: Tomas Zezula <tzezula@netbeans.org>
Log: #208528:Allow user to specify platform used for new projects
Comment 19 David Konecny 2012-05-24 00:20:39 UTC
Created attachment 119788 [details]
patch proposal

Tomas, this change caused some of our unit tests to start failing because of:

java.lang.AssertionError
	at org.netbeans.modules.java.api.common.ui.PlatformUiSupport$PlatformKey.<init>(PlatformUiSupport.java:370)
	at org.netbeans.modules.java.api.common.ui.PlatformUiSupport.storePlatform(PlatformUiSupport.java:129)
	at org.netbeans.modules.web.project.api.WebProjectUtilities.createProjectImpl(WebProjectUtilities.java:319)

(eg. http://bertram-tst.netbeans.org:8080/job/javaee/4179/testReport/).

The cause is there is no platform provider in unit test environment. It can be fixed in many ways and attached is one solution. How do you think it should be fixed? Thanks.
Comment 20 Tomas Zezula 2012-05-24 06:50:03 UTC
Hi David.
The problem is with FallbackDefaultJavaPlatform which is returned by JPM.getDefaultPlatorm() when no JavaPlatform exists but it's not returned among JavaPlatforms returned by JPM.getInstalledPlatforms().
Probably the safest fix is to provide JavaPlatformProvider for tests however I think that JPM.getInstalledPlatform should be fixed to return the FallbackDefaultJavaPlatform in case it was returned by JPM.getDefaultPlatform().

I will fix the 4 tests by adding the MockJavaPlatformProvider into them - not to depend on FDJP and then try to change the JPM to be symmetric.
Comment 21 Tomas Zezula 2012-05-24 11:23:47 UTC
I've change the JPM.getInstalledPlatforms() to return the FJP as described above.
It seems to fix the test.
jet-main e0bf4f049638
Comment 22 David Konecny 2012-05-25 03:58:00 UTC
> I've change the JPM.getInstalledPlatforms() to return the FJP 

Sounds good. Thanks.
Comment 23 Quality Engineering 2012-05-25 05:47:47 UTC
Integrated into 'main-golden', will be available in build *201205250002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e0bf4f049638
User: Tomas Zezula <tzezula@netbeans.org>
Log: #208528:Allow user to specify platform used for new projects


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo