InformationPhotography |
Tuesday, May 2. 2006Netbeans Source Version GotchaTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Hi there Daniel, may I know what really is the impact if I choose to set source level to 1.4, and if I don't?
I'm new to J2EE, and I'm not sure what repercussions (if any) it would bring to me when I am developing J2EE applications. Hope you will offer your insight into this. Thanks in advance.
The source level sets what version of Java to use when compiling the source. In my case, I was trying to use Java 5 constructs, like the new enum type (other examples would include generics or autoboxing); with the source level set to 1.4, it forces Java 1.4.x compatibility, so my code was not working.
The only reason you would want to set your source level to 1.4 is if you need to deploy to a server running the old Java 1.4.x and upgrading to 1.5.x is not an option.
Hello Daniel, thanks for the prompt reply.
I was trying out NetBeans and there was this mention in the help files that " The J2EE 1.4 and J2EE 1.3 specifications do not recommend JDK 1.5.". I have tried searching the web but could not find anything that explicitly states why this is so. Is the reason the same as what you have mentioned above? Also, it seems that although the J2EE 1.4 that is available from Sun's website is bundled with AppServer v8.2 + JDK 1.5.0, a lot of J2EE Developers are still advocating the usage of JDK 1.4.2 for J2EE 1.4... Looking forward to your insight. :)
They do not recommend it since Java 1.5 has not, by definition of its newness, been as well tested as Java 1.4 and there may be some obscure compatibility issue(s) they have not found yet. The companies making such recommendations have big expensive lawyers who insist they be extremely cautious about recommending trying anything new. If you absolutely postitively must have rock solid stability, and you have existing applications well tested with 1.4, you may want to stay with it.
I have found the performance and productivity gains of Java 1.5 to be valuable, however, and would not recommend staying with 1.4. I tend to be more on the bleeding edge than some though; I am using EJB 3 / Hibernate Annotations in production, for example. I am of the opinion that as long as your applications have a good set of tests and you test them before going into production, there is very little reason not to make use of the latest technologies to improve your productivity. Your needs may vary, however.
I would have to agree with Daniel here. Unless someone or some group is forcing you to use Java 1.4, I also recommend using Java 1.5.
I only wish my place of employment would use Java 1.5. It would make life a bit easier in my eyes.
Heya Daniel and Cliff, thanks for the valuable insight.
Unfortunately, my application has to make use of Java 1.4 (J2EE 1.4, EJB 2.x). However, I am given a choice to choose between the older JDK 1.4.2 or the newer JDK 1.5.0 (generics!) in the development of my application. So I presume that if J2EE 1.4 is used, JDK 1.4.2 should be paired with it, and if J2EE 1.5 is used, JDK 1.5.0 should be paired with it? That is the recommendation, am I correct?
That you 'have to use Java 1.4 (J2EE 1.4, EJB 2.0)' tells me you likely don't have control of the application server, or your application may need deployed on servers outside your organization. If your administrators are running Java 1.4 on your server, you will need to deploy on 1.4, and/or you must be fully J2EE spec compliant, you will have to develop using 1.4.
(P.S. J2EE 1.5 does not exist, it's called Java EE 5 now.)
To perhaps clarify things a bit better, Java doesn't compile to machine code like C/C++. When you develop in Java 5, it compiles to Java 5 bytecode that requires Java 5 on the server to run. The 'source version' checkbox in Netbeans allows you to compile to Java 1.4 bytecode using Java 5 on your development workstation; BUT this also means you cannot use any of Java 5's new features in your application as they require Java 5 bytecode to work.
You technically can use Java 5 SDK on your workstation to prepare 1.4 applications, but all you gain is the performance benefit in your IDE, you cannot use any Java 5 features in this situation.
Hi Daniel,
thanks for this help ! Greetings, from Berlin, Germany ;-) |
QuicksearchLexiyntax @ Twitter
Categories |