• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

which environment variable decide 'java -version'

Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On windows, I installed both j2sdk1.4 and jdk1.5 (1.4 for working, 1.5 for personal)
environmental variables are: PATH as 1.4/bin, JAVA_HOME is where 1.4 is.
so after these, I thought 1.4 is the version of java i am using now, but when i try 'java -version' on command line, 1.5 shows up.
If I disable PATH, 'javac' (compile) won't work, means i am still using 1.4 to compile. however, 'java' works fine.
I guess there's something i should setup as well as PATH and JAVA_HOME. maybe CLASSPATH? I wonder.
Thanks in advance.
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Path should be the main thing you need to get going. I have a couple BAT files I use to set JDK paths. By default my command windows don't have a path to a JDK or JRE so I have to run one or the other to get running. Here's one for Java 5:

Hmm, I forgot that sets JAVA_HOME, too. Maybe I needed that for ANT. Once you have the JDK path going, see if this tutorial helps with classpath and all that. Follow the link to the Sun "setting the classpath" page, too.
Yan Bai
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found where the problem is.

I have JRE1.5 (not JDK) installed under a different folder than JDK1.5. that's the reason why after PATH is setup to 1.4, 'java -version' still says it's 1.5.

after uninstall JRE, 'java -version' gave what specified in PATH env.
Lookout! Runaway whale! Hide behind this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic