This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java -version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java -version " Watch "java -version " New topic
Author

java -version

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
I have downloaded "j2sdk1.4.2" and have included it in my "PATH".
So, here is what confuses me ---
**************************
"C:\echo %PATH%" gives me
"C:\j2sdk1.4.2\bin;......", so it seems jdk1.4 is there.
But, "C:\java -version" gives me
"java version 1.3.1, Java 2 Runtime environment, SE (build1.3.1)".
****************************
Why does "java -version" still show 1.3.1 instead of 1.4.2 ? I did a serach on 1.3 on my PC and I find that some other softwares on my PC (like bea7.0, VisualCafe) seem to use jdk1.3.1.
So, my questions are ---
1. what determines the output of "java -version" ? why doesn't it show 1.4.2 after I included 1.4.2\bin in my PATH ?
2. If I need to compile a code which includes some special method that are ONLY recognized by 1.4.2, will it work on my PC ? I guess it will because I have 1.4.2 in my PATH, but I am not sure because "java -version" still shows 1.3.1.
Please help.
Thanks,
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Are you sure there's a directory named, exactly, c:\j2sdk1.4.2? The directory may be named something like c:\j2sdk1.4.2_01, for example, or it may be located elsewhere.


[Jess in Action][AskingGoodQuestions]
Masha Klimenko
Ranch Hand

Joined: Feb 04, 2004
Posts: 31
You must still have the old version on your computer. You have to uninstall 1.3 before installing 1.4, because if you put one over the other it won't work. (Also make sure CLASSPATH system variable is set)


SCJP
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
The java.exe you are executing is probably located in your Windows system32 directory.
I suggest downloading a "which" utility--it will tell you the location of an executable being picked up by the path.
In any case, having multiple versions on Java on one machine can be tricky--best advice, as already suggested by someone else, is to uninstall other versions. You may also want to delete the java.exe in your system32 directory.
-Jeff-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
I have two sdk's on my laptop. I have 1.3.1_02 that was installed by Oracle and the other one I installed myself which is 1.4.1_01.
If you open a DOS prompt and type path, you can see in which order your sdk's are installed. On my laptop, Oracle likes to be listed first. If I wanted to, I could change the order of the path variable and move the path to the 1.4.1_01 sdk to the front of the list. In fact, Oracle's JDeveloper will let you tell it which sdk you want to use, which tells me that you can have more than one installed on your computer.
Also try this:

You will basically see your jvm properties.


Thanks, leo
Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
First of all, I correct that it should be j2sdk1.4.1_02 Now the
most critical question are ----
1. suppose I do NOT un-install anything, if I compile some code
that includes some method only recognized by 1.4.2, does it work ??
2. If I un-install, do I need to uninstall the softwares that
uses jdk1.3 ? That's not what I like because I still need to use
those softwares although they are bit old.
3. can I just simply delete that "system32" file without causing any side effect ?
Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
Originally posted by leo donahue:
I have two sdk's on my laptop. I have 1.3.1_02 that was installed by Oracle and the other one I installed myself which is 1.4.1_01.
If you open a DOS prompt and type path, you can see in which order your sdk's are installed. On my laptop, Oracle likes to be listed first. If I wanted to, I could change the order of the path variable and move the path to the 1.4.1_01 sdk to the front of the list. In fact, Oracle's JDeveloper will let you tell it which sdk you want to use, which tells me that you can have more than one installed on your computer.
Also try this:

You will basically see your jvm properties.


so,
1. what do you get when you type "java -version" ?
2. do you have problem when you compile some code that's only compilable by 1.4 ?
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327

so,
1. what do you get when you type "java -version" ?
2. do you have problem when you compile some code that's only compilable by 1.4 ?


When I type java -version? I get "java version 1.3.1_02"
I haven't really memorized what the differences are between 1.3 and 1.4 but so far, I have had no problems. I'm guessing here, but I suppose that since I have two paths to two different sdk's, if I need something for a program that is not in 1.3 but in 1.4, the jre will find the right sdk for me. I'm just guessing on that, I have no proof. But i would think that the JRE would look through the entire path variable before giving up.
[ February 05, 2004: Message edited by: leo donahue ]
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Originally posted by leo donahue:
If you open a DOS prompt and type path, you can see in which order your sdk's are installed.

But remember that the windows system32 directory is usually first on the path, and usually will contain java.exe...
-J-
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Originally posted by Frank Sikuluzu:
3. can I just simply delete that "system32" file without causing any side effect ?

Yes. Windows will replace it if it needs to. But if you're feeling uncomfortable, just back it up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java -version
 
Similar Threads
How to use JDK & JRE without setting the path in environment variable
Package Statment for Directories with a period in the name
UnsupportedClassVersionError
urgent help in running examples from hf jsp servlets
Problem compiling pgm