Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Newbie - Java version and Eclipse

Thread view: 
Dom - 25 Dec 2006 00:31 GMT
I'm very confused about the version of Java that I'm running.  I need
to know because Eclipse tells me that I can't use the ForEach type of
For-Statement.

When I enter (in DOS) "java -version", I get:  java version "1.4.2_03"
When I look at the Java Control Panel, I get:  Version 1.5.0 (build
1.5.0_09-b03)
And my directories show c:\Program Files\Java\jre1.5.9_09

What is the proper way of finding the java version, how do I upgrade to
version 5, and how do I let Eclipse know I am there?

TIA,
Dom
Manish Pandit - 25 Dec 2006 01:30 GMT
Click on Window/Prererences/Java/Installed JREs. Then you can see the
JDK versions listed on the right side tab. Check the 1.5 version if not
checked already. Alternatively, you can add the 1.5 JDK using the 'add'
button.

Hope this helps!

-cheers,
Manish
Dom - 25 Dec 2006 03:36 GMT
I did everything as you suggested, but I get the same message from
Eclipse.  Should it worry me that the "java -version" command is still
saying version 1.4.2_03?

Dom

> Click on Window/Prererences/Java/Installed JREs. Then you can see the
> JDK versions listed on the right side tab. Check the 1.5 version if not
[quoted text clipped - 5 lines]
> -cheers,
> Manish
IchBin - 25 Dec 2006 04:39 GMT
> I did everything as you suggested, but I get the same message from
> Eclipse.  Should it worry me that the "java -version" command is still
[quoted text clipped - 11 lines]
>> -cheers,
>> Manish

I would clean up you Java on your machine. I would do The Following:

- Uninstall older versions of java (JDK\JRE):
Go to Menu Start \ Control Panel \ Add Remove Programs..

Look and see what Java version that are installed. It looks like you
have more than one version installed.

- Uninstall the older Java installs(JDK\JRE). Personally I would get rid
of all the installed Java versions you have and install the latest Java
JDK 1.6.0 version.

- Now Set your Dos environment vars for Java. This why you are getting
the 1.4.2_03 when you run the Java command. The JAVA_HOME is set to
1.4.2_03. So:

Go to Menu Start \ Control Panel \ System \ Advanced \ Environment vars
button. Now set you Java_Home to the Java you want to use...

Now the DOS will point to the JDK you want. You can now do what Manish
suggested from Eclipse.

Signature

Thanks in Advance...                  http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA          http://weconsultants.phpnet.us
______________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

Alex Hunsley - 25 Dec 2006 11:14 GMT
> I'm very confused about the version of Java that I'm running.  I need
> to know because Eclipse tells me that I can't use the ForEach type of
[quoted text clipped - 7 lines]
> What is the proper way of finding the java version, how do I upgrade to
> version 5, and how do I let Eclipse know I am there?

The others wrote back with some good information.
Just like to add: as well as ensuring that you have the 5.0/1.5.0 JRE
added to Eclipse (Eclipse>Preferences>Java>Installed JREs), you need to
ensure your Eclipse preferences are set to have the compiler level at
5.0. (Do this in Eclipse>Preferences>Java>Compiler level to 5.0. This
setting can also be overridden on a per-project level, so check your
project preferences too.)

The compiler level is important because it can tell a 5.0 JRE/JDK to act
like it's JDK1.4 and so on, in which case you can't use 5.0 features!
lex
Dom - 25 Dec 2006 15:26 GMT
Thanks, Alex.  Setting the compiler level did the trick.

For some reason, my "c:\Program FIles\Java" folder contains multiple
subfolders, with different version numbers.  Also, my Oracle folder,
which existed before I downloaded java, also has a java subfolder.  And
my environment variables do not include a JAVA_HOME.

Does any of this make sense?

Dom

> > I'm very confused about the version of Java that I'm running.  I need
> > to know because Eclipse tells me that I can't use the ForEach type of
[quoted text clipped - 19 lines]
> like it's JDK1.4 and so on, in which case you can't use 5.0 features!
> lex
IchBin - 25 Dec 2006 18:03 GMT
> Thanks, Alex.  Setting the compiler level did the trick.
>
[quoted text clipped - 29 lines]
>> like it's JDK1.4 and so on, in which case you can't use 5.0 features!
>> lex

Open a dos window and do a 'set' cmd. Look at the output and find out
where the older java is set. Maybe in your path.

Uninstall the other versions you do not need as I have mentioned before.
Signature

Thanks in Advance...                  http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA          http://weconsultants.phpnet.us
______________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

Alex Hunsley - 26 Dec 2006 00:20 GMT
> Thanks, Alex.  Setting the compiler level did the trick.
>
[quoted text clipped - 4 lines]
>
> Does any of this make sense?

Hi Dom
Yup, as IchBin said, you just have multiple versions of Java installed
(or leftovers from previous installs, in the least), and should make
sure any older versions are uninstalled (e.g. in Control
panel->add/remove programs, for starters). You can probably quite safely
ignore the Oracle Java folder.

Btw, can you not top post please? Bottoms posting makes threads much
easier to follow....
thanks,
Alex
ck - 26 Dec 2006 07:10 GMT
> The others wrote back with some good information.
> Just like to add: as well as ensuring that you have the 5.0/1.5.0 JRE
[quoted text clipped - 6 lines]
> The compiler level is important because it can tell a 5.0 JRE/JDK to act
> like it's JDK1.4 and so on, in which case you can't use 5.0 features!

I guess what Alex has mentioned should solve the issue. It does not
matter to Eclipse how many versions of JRE is installed on your system.
In fact you have different JRE configured for your Eclipse. That gives
you the advantage of testing your application (module/project/whatever)
for different versions of JRE.
So if you are sticking to Eclipse it should not matter what version of
JRE is installed or what command prompt shows by java -version command.
All you need to set is Compliance for your code in preferences, or you
can set individually/specifically for any particular project

Cheers,
Ck
http://www.gfour.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.