It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java version." Watch "Java version." New topic

Java version.

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hi Friends ,

I was having java 1.4 installed on my machine. Now , recently i upgraded to 1.5. However when i goto command prompt and type this :

> java -version

it still says 1.4 releated things.

Can someone let me know how would the new 1.5 come in effect. I need to use new 1.5 features like static imports , enums etc.

Thanks in Advance.

Yogendra N Joshi.

Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I don't feel that it should be in the Advanced forum
Please check your PATH variable. It probably contains a directory pointing to version 1.4 of your compiler.

[My Blog]
All roads lead to JavaRanch
Mike Guze

Joined: Jun 09, 2007
Posts: 11
Hi, You have to put the absolute path of the bin directory (in my case "C:\Archivos de programa\Java\jdk1.5.0\bin") in an environment varible called "path"; In windows have to check the system32 directory, if there are java.exe and javac.exe you have to move out them.
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hi Mike / Satou ,

I tried doing as told by you... But it didnt work out.

I moved java.exe , javaw.exe , javaws.exe from system32 folder and added an entry for PATH variable as C:\Program Files\Java\jdk1.5\bin

and then i went to cmd again and tried. Still its 1.4

Please help out.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14991

What exactly does your PATH environment variable contain now?
Did you restart the computer after changing the PATH?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
You most likely need to put the new path pointing to the Java 1.5 JDK at the front of your PATH variable. I've seen a similar problem before when another program I've installed has modified my PATH for me and over-ridden the JDK that I had specified.

In short, your system will use the first JDK it finds in your PATH. So if you have

PATH = .;C:\Program Files\Java\jdk1.4.2\bin;C:\Program Files\Java\jdk1.5\bin

you system will use the 1.4.2 JDK.

If you find that this is the case, just remove the older one, or rearrange them so that 1.5 comes first.
I agree. Here's the link:
subject: Java version.
It's not a secret anymore!