Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: "java -version" doesn't display proper value.

  1. #1
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    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
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: "java -version" doesn't display proper value.

    So on your PATH variable you have JAVA_HOME/bin and your JAVA_HOME is set to point at your 1.4 install?

    Preferably I'd install 1.6 if I was you and get rid of the other versions.

    // Json

  3. #3
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Default Re: "java -version" doesn't display proper value.

    Thanks for your reply Jason!

    That would be a good idea. But sometimes there are some dependencies like you need to compile your java files with some specific versions like 1.4/1.5/1.6 etc. So at that time when I am trying to set any specific version for compiling my source files, it is not working as my "java -version" is ONLY set to 1.5 instead of 1.4 though I am giving 1.4 paths through environment variables.

    Thats my one of the concern.

    Goldest

  4. #4
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Default Re: "java -version" doesn't display proper value.

    Some more info: This is how my environment variables look like

    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"

    There is ONLY one declaration of bin folder in path. I don't have any 1.5 path declared in the path variable before 1.4.

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

    Please suggest

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: "java -version" doesn't display proper value.

    Are you using the Eclipse IDE? There's a feature that when you create a new Java project, you can specify which version of Java you want to use. No need to mess around with the environment variables

  6. #6
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: "java -version" doesn't display proper value.

    Ok, what you want to do is install Java 1.6 latest JDK.

    When you compile programs and you want them compiled in 1.4 use the -source option.

    javac -source 1.4
    For more information see javac - Java programming language compiler

    // Json

  7. The Following User Says Thank You to Json For This Useful Post:

    goldest (November 1st, 2009)

  8. #7
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Thumbs up Re: "java -version" doesn't display proper value.

    That would be a nice way to go Json.

    Thanks a lot.

    Goldest

Similar Threads

  1. Replies: 16
    Last Post: August 27th, 2010, 04:30 PM
  2. Replies: 2
    Last Post: March 23rd, 2010, 02:38 AM
  3. Replies: 1
    Last Post: October 25th, 2009, 12:54 PM
  4. Replies: 3
    Last Post: April 20th, 2009, 09:35 AM
  5. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 11:26 AM