Reputation: 3518
How can I change the Projects Runtime Platform?
(standard NetBeans [8.1] Java Project [Java Application])
Details:
When I run the project via the IDE (Run project), the Project-Platform is used (which is Java 6).
I cannot change the Runtime Platform!
It's always: Project Platform
I tried to Manage Platforms...
, but I still can't change the value of the Runtime Platform-ComboBox.
EDIT:
As I wrote in the comments, I don't want to change the Project-Platform.
The project should be compiled with Java 6 but run with Java 8 (when click on Run project).
What I want is:
Project-Platform = Java 6 (used to compile),
Runtime-Platform = Java 8 (used to run).
Upvotes: 3
Views: 5220
Reputation: 1
Just went through this pain for Apache NetBeans 14. I was trying to set a remote debug for a Raspberry Pi.
It works only if the jdk match on both the local and remote versions. In my case I set them both to 17.
I would have expected that the default jdk on the local machine should have been able to be changed but I fail to determine how.
I am running Ubuntu on the local machine so maybe the platform cannot be changed (don't know). Moving on. Changed runtime platform
Upvotes: 0
Reputation: 21
Please look at Netbeans Project Setup - Setting the Target JDK in a Project
You just have to change the Runtime Platform at the Libraries option, that's all.
Upvotes: -1
Reputation: 17343
How can I change the Projects Runtime Platform?
Unfortunately you can't. As you point out, its value can only be Project Platform. Of course that invites the question "What is the point of even having that Runtime Platform field?".
I suspect that it may have been (unwisely) added to the GUI so that at some time in the future it will be possible to actually select a different JDK to run against. There is an open Bug Report for this: Bug 186747 - Can't Build and Run with Different Java Versions.
It's also worth noting that the Help documentation for the Run screen does not mention that Runtime Platform field. My own view is that the field should be removed until it serves a useful purpose.
What I want is: Project-Platform = Java 6 (used to compile), Runtime-Platform = Java 8 (used to run).
Unfortunately that can't be done, as shown by the open bug. The best you can do right now is:
I realize that you don't want to do that, but unfortunately there's no silver bullet in the current release of NetBeans (8.2).
An alternative approach would be to build and run using only JDK 8, but include the Animal Sniffer Maven plugin "for checking projects against the signatures of an API", to verify that your 1.6 code was not using illegal APIs. But of course that's only viable for Maven projects.
Upvotes: 1