How can I set which JDK to use for my freeform project?
Currently all Ant scripts run by the IDE are run inside the IDE's Java virtual machine, and since Ant tasks by default use the same JDK for building and running your project's source code as the JDK in which Ant itself is run, if you do nothing special your freeform project is built or run using the same JDK the IDE is running on. This might be a problem, for example if you have a project which only requires JDK 1.4 (and you have some customers using JDK 1.4) yet you want to run the NB IDE under JDK 6 for its faster and better Swing rendering: if you're not careful you could accidentally start relying on a new class/method (or bugfix) which was not present in JDK 1.4.
You can solve this just by specifying various attributes to the Ant tasks in your script, such as bootclasspath or executable. See the Ant manual for details. Since this was cumbersome such functionality has been implemented and merged into the IDE's production code as of 6.0 Milestone 4, so NetBeans 6.0 users can simply change Java Platform in the Java Sources Classpath panel of the project Properties dialog.
(Note: always use source on <javac> even if you don't mind building on a later JDK than your project requires as a minimum! JDK 5.0 changed the default source level to 1.5, so if you have a project which does not require JDK 5 language features like generics, it won't run on JDK 1.4 after being built on JDK 5.0 unless you specify source="1.4" explicitly. This advice holds for any Ant script whether you use NB or not!)
The same functionality is available also for users of NetBeans versions prior 6.0, but it's available only as separate module called Freeform Project Extras from development update center.
Applies to: NB 6.x