File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes multiple Java -version confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "multiple Java -version confusion" Watch "multiple Java -version confusion" New topic

multiple Java -version confusion

Charles Everhart

Joined: Jul 25, 2008
Posts: 1
Howdy Y'all

New to Java, just picked up the Head first Java 2nd edition and have been playing with the code.

I have downloaded jdk1.6 and have on my computer the following path.
"C:\Program Files\Java\jdk1.6.0_07\bin"

If I enter "java -version" I get the following return value
'java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)'

I can enter my code into a .java file in the "bin" folder, compile and run it and it works.

Here is my issue, if I try to run my program in a seperate folder (I added a folder "C:\Program Files\Java\jdk1.6.0_07\bin\Samples" to store programs in) I get a "(Unsupported major.minor version 50.0)" error. I researched the error and found it was because my versions didn't match.

I did a 'java -version" in my "C:\Program Files\Java\jdk1.6.0_07\bin\Samples" and it returned:
'java version "1.3.1_01"
Java(TM) SE Runtime Environment (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)'

Why did the "C:\Program Files\Java\jdk1.6.0_07\bin\Samples" and the
"C:\Program Files\Java\jdk1.6.0_07\bin" return different versions?

I also looked at the "C:\Program Files\Java\jdk1.6.0_07\sample" and it also returned a 1.3.1_01 version.

Also, is it possible to change the 1.3 version to a 1.6 version....and how.

Thanks so much for your help
minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
You can check your classpath and path variable, whether the java 6 in the path or not?

Minal Silimkar
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

The issue is that when you where in the "C:\Program Files\Java\jdk1.6.0_07\bin" and ran the java command, windows was picking up the executable from the current working directory. So it was running
"C:\Program Files\Java\jdk1.6.0_07\bin\java.exe". But when you changed directory into the Samples directory and java.exe was no longer in your current working directory, it picked up the java executable from another directory in your PATH environment variable. So in your PATH is a the bin directory of a Java 1.3.1 installation. So you will need to update your PATH environment variable to point to the newer version.

Take a look at the windows installation instructions to see how to set your PATH. You can also search this forum for help since that question is asked a lot. If you are still having problems, post a reply and we can help you out.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Originally posted by Charles Everhart:

I can enter my code into a .java file in the "bin" folder, compile and run it and it works.

p.s. You should not put your source files in the bin directory, or anywhere in the JDK (or its children) for that matter. This will cause problems in the long run. Create a "projects" or "development" or "dev" directory somewhere and do your work in there

p.p.s - Welcome to JavaRanch... sorry, I usually start my replies to new ranchers with that; but forgot to in my haste.
I agree. Here's the link:
subject: multiple Java -version confusion