Results 1 to 9 of 9
  1. #1
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Question "java -version" doesn't display proper value.

    Hi,

    I am new to java and facing a strange problem regarding java version. I have 1.4 and 1.5 both the JDKs installed on my Windows XP machine.

    When I open command prompt and try to figure out what java version I have currently, it always gives me version 1.5. Even though when I set my path to “C:\j2sdk1.4.2_12\bin” and JAVA_HOME to “C:\j2sdk1.4.2_12”, this problem still persists. I wonder what I exactly need to do so that when I set my path and JAVA_HOME to 1.4 JDK it will reflect the same in “java –version” command on the command prompt.

    Any help would be highly appreciated. Is there any chance that java –version is looking somewhere else than the environment variables?

    Please advice!

    Thanks in advance!:)

    Goldest

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Remove the 1.5 from the path. Most likely you have both on the path.

  3. #3
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Default

    Actually I have verified that. At one time I am putting ONLY one entry in the path either 1.5 or 1.4. But even after that I am getting this problem.

    Case 1:
    Path = .;C:\Program Files\Java\jdk1.5.0_12\bin;C:\Program Files\... and so on
    JAVA_HOME = C:\Program Files\Java\jdk1.5.0_12

    Case 2:
    Path = .;C:\j2sdk1.4.2_12\bin;C:\Program Files\... and so on
    JAVA_HOME = C:\j2sdk1.4.2_12

    In both the cases it displays the java version as java version "1.5.0_12"

    I don't know what exactly can be the issue.:confused:

    Please suggest.
    Last edited by goldest; 10-31-2009 at 11:42 AM.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What's the version of javac displayed in both cases?

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Default

    It's javac 1.5.0_12

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,522
    Blog Entries
    7
    Rep Power
    20

    Default

    Go to directory C:\j2sdk1.4.2_12\bin (where your virtual machine is stored) and type ".\java -version". Is there a version 1.4.2 in there? If not you simply have two 1.5 installations at different places. btw, why is the name 'j2sdk' and not 'jre'? The name 'j2sdk' suggest a development kit (compiler etc.) to me, not just the virtual machine ...

    kind regards,

    Jos
    Last edited by JosAH; 10-31-2009 at 12:21 PM.

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Question

    Here are the details as per your demand:

    For 1.4:
    C:\j2sdk1.4.2_12\bin>.\java -version
    java version "1.4.2_12"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-b04)
    Java HotSpot(TM) Client VM (build 1.4.2_12-b04, mixed mode)

    C:\j2sdk1.4.2_12\bin>.\javac -version
    javac: invalid flag: -version
    Usage: javac <options> <source files>


    For 1.5:
    C:\Program Files\Java\jdk1.5.0_12\bin>.\java -version
    java version "1.5.0_12"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b02)
    Java HotSpot(TM) Client VM (build 1.5.0_12-b02, mixed mode)

    C:\Program Files\Java\jdk1.5.0_12\bin>.\javac -version
    javac 1.5.0_12
    javac: no source files
    Usage: javac <options> <source files>


    (Extremely sorry "r035198x" for my previous post where I provided wrong Javac version)

    Any more suggestions?:confused:

    Goldest

  8. #8
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Thumbs up

    This issue is resolved by the way.

    It was the environment variables setting that was causing this issue. But when I have inserted the java bin path at the beginning of the path variable, it gave the right version on cmd. Previously I was adding it at the end of the variable value.

    Thanks to all for your valuable comments and help.:D

    Goldest

  9. #9
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Good news but I hope you realize that the first response in this thread was

    "Remove the 1.5 from the path. Most likely you have both on the path."

Similar Threads

  1. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  2. Replies: 0
    Last Post: 04-20-2009, 11:08 AM
  3. Replies: 10
    Last Post: 01-29-2009, 08:00 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •