Newbie - Java version and Eclipse

D

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
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
 
M

Manish Pandit

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
 
D

Dom

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
 
I

IchBin

Dom said:
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
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.

--
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-)
 
A

Alex Hunsley

Dom said:
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?

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
 
D

Dom

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

IchBin

Dom said:
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
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.
--
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-)
 
A

Alex Hunsley

Dom said:
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?

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
 
C

ck

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!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top