Sign in to follow this  
one mind

[java] Java 1.4 or Java 5?

Recommended Posts

Hi, I just started an intro to cs course at uni and we are using java. The link from the courses website says download java 1.4. I noticed at javas website that there is a newer version (Tiger 5.0) and even a video from the creator telling me to download it :) Should i get 5 or the old one? If i get 5, are the changes so much that my code wont work on my teachers computer? I would contact him but its still holidays and i wanted to get a head start :) Thanks for any info

Share this post


Link to post
Share on other sites
There's a compiler flag (something like -target 1.4, check the javadocs) which will generate bytecode for 1.4 VMs. It should also generate warnings if you use any features/classes that aren't avalible in 1.4.

If you use an IDE like Eclipse there's a setting in the compiler options to specify this.

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
There's a compiler flag (something like -target 1.4, check the javadocs) which will generate bytecode for 1.4 VMs. It should also generate warnings if you use any features/classes that aren't avalible in 1.4.

If you use an IDE like Eclipse there's a setting in the compiler options to specify this.
eclipse is actually pre-set to use the 1.4 compliance.

Share this post


Link to post
Share on other sites
You can't use Java 5.0 with eclipse unless you get the newest stable beta version 3.1 as far as I could see in the recent weeks and even then you have to go in the compiler option and enable it since it is set for 1.4 by default

Share this post


Link to post
Share on other sites
You'll love the features 5 provides... auto-boxing, generics, typesafe enumeration; all good stuff. Get started with 4, but keep 5 in mind.

Share this post


Link to post
Share on other sites
Enums are a great addition, about time!

Generics are just syntathic sugar, and many people complain on its design. I never ran into trouble with these, but you should learn Collections both the "1.4 way" and the "tiger (Java 5) way".

Auto boxing is a dangerous thing, in my opinion. ints are ints, Integers are Integers. =D

That being said... I still suggest you download Java 5. It's the natural evolution of the language, even with all its bugs and problems, no one will stop it from going stable, replacing 1.4.

Son Of Cain

Share this post


Link to post
Share on other sites
I think most everyone missed out on one of the most important issues when choosing which version to use: market saturation.

Simply put, there are far more computers out there that have JRE 1.4 than 1.5 (5.0). If you want your code to have the most compatibility, use 1.4. However, I'm sure that about a year from now, anything less than 1.5 will be a joke, but it's always something you need to plan for.

I can say with high certainty that most businesses do not use 1.5. Takes too much time to upgrade something that is rarely used anyway.

If, however, you don't care about this stuff, and want to learn Java as it is today, use 1.5. (I suppose it's wholly dependent on what your textbook is teaching). It's not like they're going to remove Generics or anything in a future release (I hope not anyway) without breaking a lot of stuff. Sun has been keen on maintaining backwards compatibility (mostly, I'm sure some of you can cite examples where your code broke).

So there you have it.

Share this post


Link to post
Share on other sites
I recommend learning both, and probably learning 1.4 first. Like was said above, 1.5 has some nice features (mainly syntactic sugar) that can help you develop a bit quicker in some instances, but learning 1.4 first will probably help you see what's going on behind the generics and autoboxing, etc. It seems like one of the things that slows people down when trying to learn about any computer-related subject (not just programming) is not knowing what's actually going on under-the-hood and then getting unexpected side-effects as a result. Try each one out a little bit though and go with what feels natural and what you can grasp easiest.

Share this post


Link to post
Share on other sites
I love the 1.5 features. Doing a foreach loop through a generic container is FUN!

But anyway, if your class is using 1.4 then you should stick with 1.4. Might want to ask your professor about this, I'm pretty sure that he will tell you that in-class assignments will be required to be in 1.4.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this