• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which environment variable decide 'java -version'

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic