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.
Im trying to compile code generated by the Apache Axis wsdl2java utility. The code is sprinkled with references to org.apache.axis.enum.* which generates an error and a helpful message: (try source 1.4 or lower to use enum as an identifier) I put -source 1.4 in Additional Compile Options and it had no effect; I get the same errors about enum being a keyword in release 1.5. I put -source 1.4 bob in Additional Compile Options (thinking that the field was being ignored) and get a javac usage message. So the additional options are being passed in. I put -source 1.4 target 1.4 in Additional Compile Options (hoping that making the two the same would make something happy happen) and I get the error message: javac source release 1.5 requires target release 1.5 This sounds like my request for source 1.4 is just plain being ignored. When I try javac source 1.4 at the command line, it works like a charm.
Did you try to change "Java Platform" property in project properties? You are not supposed to set these settings in Additional Compiler Options.
Confirmed for a standard application, IDE 4.0 Beta 2, JDK 1.5. I wanted to get rid of "[...] uses unchecked or unsafe operations" (which is related to generics) in code written for JDK 1.4. On the command line, adding -source 1.4 is all that is required. Adding as a compiler option in the project doesn't work (ignored). Adding "-source 1.4 -target 1.4" (without the quotes) produces the error "javac: source release 1.5 requires target release 1.5", which means that -target is recognised and -source is silently ignored. Java Platform is not a good solution. If it were, there would be no -source compiler flag, and developers would just change the path to a previous JDK, foregoing any enhancements, right? (A more advanced solution might be to make this a file-specific setting, like text encoding, but I don't want to jump ahead of things.) The second problem is that a compiler option is *silently* ignored, which leads to time being wasted while the user is trying to find out what is going on. I also didn't find a way to see everything that is being passed to the compiler (maybe through Ant, somehow?).
Another argument: to deploy with JDK 1.5 to pre-1.5 JRE's, either -source must be set before 1.5, which implies -target 1.4, or -target must be set before 1.5, which requires -source to be set before 1.5 as well. That means that JDK 1.5 cannot be used with 4.0 Beta 2 in many situations, which seems quite inconvenient.
Correction (I wish I could edit some of the text I wrote before): a pre-1.5 JDK would be necessary anyway (see Cross-Compilation Options in the documentation for javac, which should illustrate that requirement with an example like new BigDecimal(0), which previously promoted 0 to double but now invokes the new constructor BigDecimal(int), right (not verified)?). However, if it is necessary to identify the platform at the IDE level, and this is not done by inspecting the additional options to the compiler (which seems preferable, because then they could also be checked for consistency), this still should not mean silently ignoring an option like -source (I have not checked -bootclasspath yet), keeping the user in the dark about that rather than actively advising what to do instead... and why! I'm also curious whether it will use that platform's javac, see my question about why javac would offer cross compilation options in the first place.
Reassigning for evaluation.
The problem is that the ant script already passes the source and target options to the javac command. Their value is taken from the used Java plarform. If you want to change it, you may either create new JDK 1.4 platform. Or you can use JDK 5.0 and set the properties javac.source, javac.target in the file project.properties to the value 1.4.
Jano, shouldn't we provide UI for that?
Doesn't the UI spec already cover this?
*** This issue has been marked as a duplicate of 45374 ***