diff values for java.home

H

harryos

hi
i have installed java to E:\Java\jdk1.6.0_05 on my WinXP machine and
it has jre on E:\Java\jre1.6.0_05 .
There is also a jre folder at E:\Java\jdk1.6.0_05\jre


I have set Env variable on my system as JAVA_HOME=E:\Java\jdk1.6.0_05
so at the cmd prompt ,when i try
echo %JAVA_HOME% i get
E:\Java\jdk1.6.0_05

Now i wrote some code like below to get System properties

Properties props=System.getProperties();
Set<String> pairs=props.stringPropertyNames();
Iterator<String> it=pairs.iterator();
while(it.hasNext()){
String key=it.next();
System.out.print(key+"=");
String val=props.getProperty(key);
System.out.println(val);
}

when i run this from the cmd prompt i get an output where
java.home=E:\Java\jre1.6.0_05

Then i tried the same code inside a jsp script in a web application
using NetBeansIDE ,there i get
java.home=E:\Java\jdk1.6.0_05\jre


i am confused by these 3 different values.Should i not get java.home
as what i set for JAVA_HOME in the env variables?

thanks
harry
 
A

Arne Vajhøj

harryos said:
i have installed java to E:\Java\jdk1.6.0_05 on my WinXP machine and
it has jre on E:\Java\jre1.6.0_05 .
There is also a jre folder at E:\Java\jdk1.6.0_05\jre

I have set Env variable on my system as JAVA_HOME=E:\Java\jdk1.6.0_05
so at the cmd prompt ,when i try
echo %JAVA_HOME% i get
E:\Java\jdk1.6.0_05

Now i wrote some code like below to get System properties

Properties props=System.getProperties();
Set<String> pairs=props.stringPropertyNames();
Iterator<String> it=pairs.iterator();
while(it.hasNext()){
String key=it.next();
System.out.print(key+"=");
String val=props.getProperty(key);
System.out.println(val);
}

when i run this from the cmd prompt i get an output where
java.home=E:\Java\jre1.6.0_05

Then i tried the same code inside a jsp script in a web application
using NetBeansIDE ,there i get
java.home=E:\Java\jdk1.6.0_05\jre


i am confused by these 3 different values.Should i not get java.home
as what i set for JAVA_HOME in the env variables?

Not necesarrily.

System.getProperty("java.home") returns where the Java running the
program is.

JAVA_HOME is an environement variable used by some startup scripts to
decide what Java to use.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top