Newbie - Java version and Eclipse

Discussion in 'Java' started by Dom, Dec 25, 2006.

  1. Dom

    Dom Guest

    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
    Dom, Dec 25, 2006
    #1
    1. Advertising

  2. 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
    Manish Pandit, Dec 25, 2006
    #2
    1. Advertising

  3. Dom

    Dom Guest

    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

    Manish Pandit wrote:
    > 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, Dec 25, 2006
    #3
  4. Dom

    IchBin Guest

    Dom wrote:
    > 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
    >
    > Manish Pandit wrote:
    >> 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

    >

    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-)
    IchBin, Dec 25, 2006
    #4
  5. Dom

    Alex Hunsley Guest

    Dom wrote:
    > 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
    Alex Hunsley, Dec 25, 2006
    #5
  6. Dom

    Dom Guest

    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



    Alex Hunsley wrote:
    > Dom wrote:
    > > 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
    Dom, Dec 25, 2006
    #6
  7. Dom

    IchBin Guest

    Dom wrote:
    > 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
    >
    >
    >
    > Alex Hunsley wrote:
    >> Dom wrote:
    >>> 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

    >

    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-)
    IchBin, Dec 25, 2006
    #7
  8. Dom

    Alex Hunsley Guest

    Dom wrote:
    > 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
    Alex Hunsley, Dec 26, 2006
    #8
  9. Dom

    ck Guest

    > 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
    ck, Dec 26, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page