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 55665 - source and target compiler argument confusion
Summary: source and target compiler argument confusion
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-01 09:47 UTC by Milan Kubec
Modified: 2011-08-31 14:05 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2005-03-01 09:47:11 UTC
[NetBeans 4.1]

Users are confused by Source Level and Java
Platform and do not know how to setup compiler
arguments 'javac.target' and 'javac.source'. UI
must be explicit about what means to set Source
Level and what means to set Java Platform and how
is it related on compiler arguments. 
Also there should be some note about it when user
selects node Compiling in Project Properties,
because both these arguments are in fact compiler
arguments and users are looking for them there.
Comment 1 Milan Kubec 2005-03-01 10:31:24 UTC
Take a look at issue #55598, it's related.

<another comment from nbdev>
I'm working with J2SE 6.0.  Latest 6.0 builds have 1.6 target for
javac, but java doesn't support new class format yet.  So, to use 6.0
with NetBeans I need to change javac.source and javac.target
properties in project.properties to 1.5.  BTW I've just edited this
file for this, is there any other way to do this?
So, the first problem here is that NetBeans choose these properties
based on active platform's version, not on default javac option (not
sure if this is possible to implement though)
The second problem is that NetBeans overwrite these changes every time
I change target platform.  IMHO it shouldn't do this since as soon as
user do specify some properties he/she relies on this (e.g. if he/she
specify   target 1.4 NetBeans should always generate class-files which
can be used with jdk1.4).

Is there any way to resolve these problems?  And are there any plans
to make these properties configurable from IDE?
</another comment from nbdev>
Comment 2 Milan Kubec 2005-03-07 11:04:50 UTC
<another comment>
I am observing an interesting change from NetBeans EA2 to Beta
regarding how to set your project to use J2SE 5.0.

In EA2, if you want to have your project to use J2SE 5.0,
from the properties window, you select General and
then you can select J2SE 5.0 java platform. And that is
all you have to do.

Now in Beta, the General option is replaced with
Sources and Library options. (This change is fine with me.)

Now as a default, the Sources option is selected.  Here if
you try to change source level in the bottom of the right
pane, you don't see 1.5 option. (This is not fine with me.)
Instead you have to choose Libraries option first then add
J2SE 5.0 there and then you get back to Sources option, you
see 1.5. Then you have to choose 1.5 as well. This is
the 2nd step you have to do.  (This is not fine with me.)

To me, this change seems to be less intuitive than EA2
behavior. At least, I thought the IDE should have 1.5 option
under Sources option window.  Any insight? 
</another comment>

I would say we should address the issue.
Comment 3 Milan Kubec 2005-03-07 11:08:49 UTC
Another related ENHANCEMENT: #53936.
Comment 4 Milan Kubec 2005-03-14 12:41:31 UTC
I think that setting -source and -target compiler options must be independent
from selected Platform, provided that selected platform supports them, otherwise
user will be asked to select such values that are supported by selected platform.
Comment 5 jrojcek 2005-10-14 13:14:04 UTC
An idea how this could be fixed. Put 2 combo boxes into the Compiling panel:

Source Compatibility: |_Platform Default (1.5)____v_|
Class File Compatibility: |_Platform Default (1.5)____v_|

Initial value is "Platform Default (<version>)". It represents the platform version value taken from the 
selected platform in the Libraries panel. Changing the selected platform in the libraries panel changes 
the version number shown in parentheses. If this item is selected then no parameter is actually passed 
to compiler. If the user wants to change the default, she can choose from these values in the combo 
box:
---
Platform Default (1.5)
1.5 - this means the user wants to explicitly pass 1.5 to compiler options
1.4
1.3
1.2
1.1 - I'm not sure which is the possible lowest number
---

I think this would work well for all users who don't want to change the source and target level explicitly 
and also for those who want to set those values to specific versions.

Would this work for users complaining about current behavior? And is it possible to implement it this 
way?
Comment 6 rationalpi 2007-07-16 18:25:12 UTC
Here is a work around for anyone needing to compile to Java 1.4 using the 1.5 or 1.6 JDK.
I think the issue should still be fixed. The problem is serious enough that a professor has
documented it in his NetBeans tutorial for his students as something that doesn't work
in NetBeans.

Work Around:
1. Right-click on Project and select Properties
2. Select Sources
3. Set the source level to 1.4
4. Select Build -> Compiling
5. Specify "-target 1.4" (without the quotes) for the Additional Compiler Options field.
6. Click the OK button.

World's Fastest Java NetBeans 5.5 Tutorial
http://wws2.uncc.edu/tpw/tpwJavaNtebeansTutorial/index.html
Comment 7 jrojcek 2007-07-17 10:29:19 UTC
Please review the UI proposal posted in earlier comment. If it works well, I would update the project UI specs of all project types affected by this change.
Comment 8 olegsukhodolsky 2007-07-17 11:17:41 UTC
the suggested UI looks fine for me.
Comment 9 Andrei Badea 2007-07-17 13:44:57 UTC
Probably needs to be done in the Java EE project types too.
Comment 10 Tomas Zezula 2007-09-06 20:24:11 UTC
Most of the issue is fixed. Changing source in project's customizer sets both javac.source & javac.target. The default
value of source level is set not to JDK version but rather to language fatures. 1.3 for JDK 1.3, 1.4 for JDK 1.4 1.5,
for JDK 1.5 & 1.6. The only unsolved problem is when you need to set different source and target, but it can be simply
done in the  project.properties by setting the javac.target property.