This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 64160 - Make it easier to set up a freeform project to use a specific JDK
Summary: Make it easier to set up a freeform project to use a specific JDK
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Freeform (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker with 3 votes (vote)
Assignee: Jesse Glick
URL: http://wiki.netbeans.info/wiki/view/F...
Keywords: UI
: 69676 79547 82828 91454 91455 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-12 20:01 UTC by Jesse Glick
Modified: 2007-02-13 17:21 UTC (History)
6 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Screenshot (24.30 KB, image/png)
2006-10-11 17:25 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2005-09-12 20:01:18 UTC
Since all Ant processes are run in-VM (see issue #41689) and there are no
immediate plans to change this, people who wish to build and/or run a freeform
project with a specific JDK (rather than the "default" JDK used by the IDE
itself) have a hard time of it. You can instruct Ant to use a different JDK for
each task (<java>, <javac>, <javadoc>), by specifying different boot classpaths
and/or executables, but

1. Most people do not realize this.

2. Far from obvious how to handle a legacy Ant script that cannot be edited.

3. User may wish to still be able to use the default JDK in which Ant is running
(might just be more convenient from the command-line, or other team members may
prefer this) while still having the option to use a specific JDK (from the IDE,
a continuous builder machine, etc.).

4. For IDE usage, would also need to specify <classpath mode="boot"> in
project.xml, which is cumbersome, especially as the current GUI does not provide
an option to edit this field.

The IDE should smooth over these problems with a wizard or similarly
discoverable GUI feature that sets up a freeform project to work adequately with
specific JDKs out of the box. For example, it could create a wrapper script
(e.g. nbproject/jdk.xml) that would <import> the main build.xml but first read a
nbproject/private/jdk.properties file containing e.g.

jdk.home=/space/jdk1.4.2_09

and then use <presetdef> to set up <java>, <javac>, and <javadoc> to use this
JDK by default. Furthermore, project.xml would use <properties-file> to load
jdk.properties and define e.g.

<classpath mode="boot">${jdk.home}/lib/rt.jar</classpath>

in each <compilation-unit>. project.xml would call all targets in jdk.xml,
rather than build.xml.

Then, the Libraries panel of the freeform project would have a pulldown for the
registered JDK to use, just as in a j2seproject, which would simply write to
jdk.properties, thus affecting both Ant's behavior and the IDE's code
completion, etc. This should solve #1-#4 adequately.

The GUI could also warn you if you had selected a JDK version which was too old
for the currently selected Source Level, as for j2seproject's.

Should also check that stack trace hyperlinking for JDK classes works correctly
- I think it would, but not sure.
Comment 1 Jan Lahoda 2005-12-01 13:43:37 UTC
*** Issue 69676 has been marked as a duplicate of this issue. ***
Comment 2 Jesse Glick 2005-12-26 13:28:54 UTC
See issue #63541 for ideas on using <presetdef> in this way. One little problem
is that Ant currently prints a warning if you override the plain definition of
some task with a preset of the same name. It's harmless but does not look nice.
On the other hand, it serves as a reminder that <javac> etc. are not doing
exactly the same thing as they would otherwise do. We could consider making some
AntLogger in the IDE suppress these warnings, so they only appear in verbose
mode or from the command line.
Comment 3 Jesse Glick 2006-02-20 00:30:56 UTC
So I implemented this in the Freeform Project Extras module. Don't know whether
we should leave this open (1) until promo-H when I presume we could put a
refined version in the main java/freeform module; (2) until I can get the update
published on nbextras.org; (3) now?

Anyway, something to play with. Should be on alpha AU soon for dev builds, can
make a binary NBM available to others upon request.

Checking in templates/skeletal/build.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/skeletal/build.xml,v
 <--  build.xml
new revision: 1.2; previous revision: 1.1
done
Checking in javahelp/org/netbeans/modules/ant/freeform/samples/docs/map.xml;
/shared/data/ccvs/repository/ant/freeform/samples/javahelp/org/netbeans/modules/ant/freeform/samples/docs/map.xml,v
 <--  map.xml
new revision: 1.4; previous revision: 1.3
done
RCS file:
/shared/data/ccvs/repository/ant/freeform/samples/javahelp/org/netbeans/modules/ant/freeform/samples/docs/jdk.html,v
done
Checking in javahelp/org/netbeans/modules/ant/freeform/samples/docs/jdk.html;
/shared/data/ccvs/repository/ant/freeform/samples/javahelp/org/netbeans/modules/ant/freeform/samples/docs/jdk.html,v
 <--  jdk.html
initial revision: 1.1
done
Checking in javahelp/org/netbeans/modules/ant/freeform/samples/docs/toc.xml;
/shared/data/ccvs/repository/ant/freeform/samples/javahelp/org/netbeans/modules/ant/freeform/samples/docs/toc.xml,v
 <--  toc.xml
new revision: 1.4; previous revision: 1.3
done
Checking in templates/skeletal/nbproject/netbeans-targets.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/skeletal/nbproject/netbeans-targets.xml,v
 <--  netbeans-targets.xml
new revision: 1.2; previous revision: 1.1
done
RCS file:
/shared/data/ccvs/repository/ant/freeform/samples/templates/skeletal/nbproject/nbjdk.properties,v
done
Checking in templates/skeletal/nbproject/nbjdk.properties;
/shared/data/ccvs/repository/ant/freeform/samples/templates/skeletal/nbproject/nbjdk.properties,v
 <--  nbjdk.properties
initial revision: 1.1
done
Checking in templates/skeletal/nbproject/project.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/skeletal/nbproject/project.xml,v
 <--  project.xml
new revision: 1.3; previous revision: 1.2
done
Checking in templates/anagram/lib/nbproject/netbeans-targets.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/lib/nbproject/netbeans-targets.xml,v
 <--  netbeans-targets.xml
new revision: 1.2; previous revision: 1.1
done
Checking in templates/anagram/lib/nbproject/file-targets.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/lib/nbproject/file-targets.xml,v
 <--  file-targets.xml
new revision: 1.2; previous revision: 1.1
done
Checking in templates/anagram/lib/nbproject/project.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/lib/nbproject/project.xml,v
 <--  project.xml
new revision: 1.2; previous revision: 1.1
done
Checking in templates/anagram/nbproject/file-targets.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/nbproject/file-targets.xml,v
 <--  file-targets.xml
new revision: 1.2; previous revision: 1.1
done
RCS file:
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/nbproject/nbjdk.properties,v
done
Checking in templates/anagram/nbproject/nbjdk.properties;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/nbproject/nbjdk.properties,v
 <--  nbjdk.properties
initial revision: 1.1
done
Checking in templates/anagram/nbproject/netbeans-targets.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/nbproject/netbeans-targets.xml,v
 <--  netbeans-targets.xml
new revision: 1.2; previous revision: 1.1
done
Checking in templates/anagram/nbproject/project.xml;
/shared/data/ccvs/repository/ant/freeform/samples/templates/anagram/nbproject/project.xml,v
 <--  project.xml
new revision: 1.2; previous revision: 1.1
done
Checking in manifest.mf;
/shared/data/ccvs/repository/ant/freeform/samples/manifest.mf,v  <--  manifest.mf
new revision: 1.6; previous revision: 1.5
done
Checking in build.xml;
/shared/data/ccvs/repository/ant/freeform/samples/build.xml,v  <--  build.xml
new revision: 1.4; previous revision: 1.3
done
Checking in src/org/netbeans/modules/ant/freeform/samples/Bundle.properties;
/shared/data/ccvs/repository/ant/freeform/samples/src/org/netbeans/modules/ant/freeform/samples/Bundle.properties,v
 <--  Bundle.properties
new revision: 1.6; previous revision: 1.5
done
Checking in src/org/netbeans/modules/ant/freeform/samples/layer.xml;
/shared/data/ccvs/repository/ant/freeform/samples/src/org/netbeans/modules/ant/freeform/samples/layer.xml,v
 <--  layer.xml
new revision: 1.6; previous revision: 1.5
done
RCS file:
/shared/data/ccvs/repository/ant/freeform/samples/src/org/netbeans/modules/ant/freeform/jdkselection/SelectJdkAction.java,v
done
Checking in src/org/netbeans/modules/ant/freeform/jdkselection/SelectJdkAction.java;
/shared/data/ccvs/repository/ant/freeform/samples/src/org/netbeans/modules/ant/freeform/jdkselection/SelectJdkAction.java,v
 <--  SelectJdkAction.java
initial revision: 1.1
done
RC
Comment 4 lordpixel 2006-05-19 21:13:45 UTC
I have just had to downgrade to running Netbeans in JDK 1.4 to compile a big
project with a complex legacy Ant script that I cannot change due to this
limitation.

This restriction is pretty bad, and the documentation is awful. Perhaps that's
because I didn't want to believe it would be this hard, but it was only upon
reading this very well written and clear defect that I understood what I would
have to do.
Comment 5 Jesse Glick 2006-05-19 23:35:27 UTC
For what it's worth, the feature is already available on nbextras.org. Not very
polished nor well tested but should help. Needs to be improved to cover more
situations and properly integrated into the regular IDE.
Comment 6 Jesse Glick 2006-07-01 17:15:56 UTC
*** Issue 79547 has been marked as a duplicate of this issue. ***
Comment 7 Jesse Glick 2006-08-16 19:28:54 UTC
Module available on nbextras.org, FYI. More info in FAQ.
Comment 8 Jesse Glick 2006-08-16 19:29:13 UTC
*** Issue 82828 has been marked as a duplicate of this issue. ***
Comment 9 lordpixel 2006-08-18 15:24:32 UTC
I downloaded and installed this into 5.5beta2, and I selected JDK 1.4 from the
menu as described. Unfortunately it's clearly still using the 1.5 or 1.6 compiler.

Here's the trace produced when I get Netbeans to run Ant in debug mode:

public class DBConn implements java.sql.Connection {
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
U:\build.xml:611: Compile failed; see the compiler error output for details.
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:933)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:240)
        at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:293)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131)

The issue here is a class is a wrapper of java.sql.Connection - clearly it is
not using the 1.4 bootclasspath, because it is complaining about a method
introduced in a later version not existing. The -Xlint:deprecated is also a dead
give away this is Javac 1.5 or later (amazingly, even in verbose mode, the
compiler used is not printed by Ant!)

Is this backtrade enough info to figure out what's going on?
Comment 10 Jesse Glick 2006-08-18 16:15:11 UTC
Working fine for me in a 5.5 dev build w/ the version downloaded from
nbextras.org. The quoted part of the log is useless. Look instead at -jdk-*
targets, in particular for the log line that looks like this:

nbjdk.active=Java_HotSpot_TM__Client_VM_1.6.0-rc-b95 nbjdk.home=/space/jdk1.6
nbjdk.java=/space/jdk1.6/bin/java nbjdk.javac=/space/jdk1.6/bin/javac
nbjdk.javadoc=/space/jdk1.6/bin/javadoc
nbjdk.bootclasspath=/space/jdk1.6/jre/lib/resources.jar:/space/jdk1.6/jre/lib/rt.jar:/space/jdk1.6/jre/lib/sunrsasign.jar:/space/jdk1.6/jre/lib/jsse.jar:/space/jdk1.6/jre/lib/jce.jar:/space/jdk1.6/jre/lib/charsets.jar:/space/jdk1.6/jre/classes:/space/jdk1.6/jre/lib/ext/sunjce_provider.jar:/space/jdk1.6/jre/lib/ext/sunpkcs11.jar:/space/jdk1.6/jre/lib/ext/dnsns.jar:/space/jdk1.6/jre/lib/ext/localedata.jar
nbjdk.valid=true have-jdk-1.4=${have-jdk-1.4} have-jdk-1.5=${have-jdk-1.5}

(printed in verbose or debug mode).

Remember that the IDE is just running an Ant target, so you can use the Ant
debugger etc. to trace exactly what it is doing. In fact the same build should
work from the command line, so long as you define -Dnetbeans.user=$userdir or
-Duser.properties.file=$userdir/build.properties so it can find JDK
installations by name.
Comment 11 Jesse Glick 2006-10-10 19:49:20 UTC
cvs rtag -b -r BLD200610091800 freeform_jdk_64160 java/freeform
Comment 12 Jesse Glick 2006-10-11 01:48:17 UTC
In progress on the branch.
Comment 13 Jesse Glick 2006-10-11 17:25:11 UTC
Created attachment 35114 [details]
Screenshot
Comment 14 Jesse Glick 2006-10-11 17:35:35 UTC
Jano, can I get you to look at the attached screenshot and see if it looks sane?
That is the extent of the UI for this RFE.
Comment 15 jrojcek 2006-10-12 11:23:28 UTC
Looks good to me. Just a cosmetic comment: The Java Platform description uses *will be* while the 
classpath description uses *is*:

- The Java Platform will be used...
- This classpath is used...

I'm really not sure which one is correct. The other one should be corrected.
Comment 16 Jesse Glick 2006-10-13 00:03:51 UTC
Checking in nbproject/project.xml;
/shared/data/ccvs/repository/java/freeform/nbproject/project.xml,v  <--  project.xml
new revision: 1.17; previous revision: 1.16
done
Checking in src/META-INF/services/org.apache.tools.ant.module.spi.AntLogger;
/shared/data/ccvs/repository/java/freeform/src/META-INF/services/org.apache.tools.ant.module.spi.AntLogger,v
 <--  org.apache.tools.ant.module.spi.AntLogger
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/netbeans/modules/java/freeform/Classpaths.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/Classpaths.java,v
 <--  Classpaths.java
new revision: 1.10; previous revision: 1.9
done
Checking in src/org/netbeans/modules/java/freeform/JavaActions.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/JavaActions.java,v
 <--  JavaActions.java
new revision: 1.14; previous revision: 1.13
done
Checking in src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java,v
 <--  JavaProjectGenerator.java
new revision: 1.10; previous revision: 1.9
done
Checking in src/org/netbeans/modules/java/freeform/JavaProjectNature.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/JavaProjectNature.java,v
 <--  JavaProjectNature.java
new revision: 1.14; previous revision: 1.13
done
Checking in
src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java,v
 <--  JdkConfiguration.java
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/netbeans/modules/java/freeform/jdkselection/Logger.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/jdkselection/Logger.java,v
 <--  Logger.java
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/netbeans/modules/java/freeform/jdkselection/jdk.xml;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/jdkselection/jdk.xml,v
 <--  jdk.xml
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/netbeans/modules/java/freeform/jdkselection/jdk.xsl;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/jdkselection/jdk.xsl,v
 <--  jdk.xsl
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/netbeans/modules/java/freeform/ui/Bundle.properties;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/ui/Bundle.properties,v
 <--  Bundle.properties
new revision: 1.18; previous revision: 1.17
done
Checking in src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.form;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.form,v
 <--  ClasspathPanel.form
new revision: 1.5; previous revision: 1.4
done
Checking in src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.java;
/shared/data/ccvs/repository/java/freeform/src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.java,v
 <--  ClasspathPanel.java
new revision: 1.11; previous revision: 1.10
done
Comment 17 Jesse Glick 2006-12-22 14:47:51 UTC
*** Issue 91454 has been marked as a duplicate of this issue. ***
Comment 18 _ wadechandler 2006-12-23 00:35:45 UTC
1) Just a comment about the screen shot and consistency.  The other projects
have the Java Platform selection above the other paths.  It might be better to
keep them consistent.

2) Will the selected platform be used to compile when the project is run from
inside the IDE as well?  Just that it makes sense to do so as the user may be
using a Java 1.6 or future 1.7 JVM for the free-form project when the IDE may be
run on say 1.5 or vice versa.  That way any issues such as a missing constructor
or method because of overloading will be handled correctly and not leave the
issue hard to track down for an unsuspecting user.  

I have run into issues such as this, and it would not be addressed by only using
the code completion features if the user did not do something such as open all
the files and look at them all as compilation can succeed only to leave issues
at runtime.  A perfect example is if the IDE is run on 1.5 and the user has the
platform set to 1.4 and source level at 1.4 (assuming only code completion uses
1.4 and not compilation).  They may have a file which someone used something
such as a BigDecimal constructor.  In 1.5 there is BigDecimal(int) and
BigDecimal(double), however in 1.4 there is only BigDecimal(double).  If a
source file calls "new BigDecimal(5);" this will cause an issue if the IDE is
run on 1.5 and ANT uses 1.5 to compile the project and the user expects to be
able to run it on 1.4.  What will happen is the 1.5 compiler will link to the
method BigDecimal(int) and when run on a 1.4 JVM the user would get a
LinkageError.  If the user had compiled the sources with 1.4 the compiler would
have promoted the int to a double for the call, and the correct method would
have been linked to, and the user would be able to run the final classes on a
1.4 or 1.5 JVM.  The main issue is that there are transparent issues which arise
with both things (ANT script targets and IDE features) not using the same Java
platform.
Comment 19 Jesse Glick 2007-02-13 17:18:31 UTC
*** Issue 91455 has been marked as a duplicate of this issue. ***
Comment 20 Jesse Glick 2007-02-13 17:21:28 UTC
Wade's #1 (GUI location of Java Platform in freeform vs. other project types) -
could be moved up. I have no opinion. Jano, if you care about this, just file a
bug in java/freeform about it.

#2 - yes, try it.