Home arrow static arrow Java Programming [Archive] - System.getProperty("java.home") gets wrong value!?!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - System.getProperty("java.home") gets wrong value!?!
This topic has 6 replies on 1 page.

Posts:12
Registered: 7/14/03
System.getProperty("java.home") gets wrong value!?!  
Jun 25, 2004 12:59 AM



 
Hi there,

I set the JAVA_HOME environment-property on my WinXP to

"C:\programs\f-j\java"


but when I call

System.getProperty("java.home") 


I get

"C:\programs\f-j\java\jre\"


does anyone know why?
 

Posts:342
Registered: 5/22/98
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 25, 2004 1:55 AM (reply 1 of 6)



 
If I remenber correctly, the java.home variable comes from the registry. Open regedit and look at the following Key:

\\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

The CurrentVersion value will give you the name of the next key to check. For example, if it says 1.4, look at :

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.4

This will have a Key called JavaHome and this is where javaj.home comes from.

Graeme
 

Posts:342
Registered: 5/22/98
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 25, 2004 2:00 AM (reply 2 of 6)



 
Ignore that last reply, I seem to have remembered incorectly. Sorry about that.

Graeme
 

Posts:342
Registered: 5/22/98
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 25, 2004 2:06 AM (reply 3 of 6)



 
I did some testing and it seems that the JAVA_HOME environment variable has no impact on the java.home System property. It seems to be the parent of the directory which contains java.exe / javaw.exe. You will probable find that the java.exe you are using is in C:\programs\f-j\java\jre\bin.

Graeme
 

Posts:12
Registered: 7/14/03
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 30, 2004 7:10 AM (reply 4 of 6)



 
I did some testing and it seems that the JAVA_HOME
environment variable has no impact on the java.home
System property. It seems to be the parent of the
directory which contains java.exe / javaw.exe. You
will probable find that the java.exe you are using is
in C:\programs\f-j\java\jre\bin.

unfortunately not. That would help solve the problem easily. What I wonder is how to tell my system to use the jdk-Java version and not the jre-java version. This is of interest, because when using any third party software assuming you have the jdk installed and looking for executables in your bin folder like "javah"... they always assume that you have installed the wrong version. Is there any workaround?

Sincerely
Charly
 

Posts:2,830
Registered: 9/1/03
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 30, 2004 7:17 AM (reply 5 of 6)



 
search around on the forum, i remember discussions about this..

of course, you can pass the value for the property (if it helps) at runtime
via:

java -djava.home="hello"

or some similar synax (check java -h).
 

Posts:13,769
Registered: 00-11-29
Re: System.getProperty("java.home") gets wrong value!?!  
Jun 30, 2004 7:42 AM (reply 6 of 6)



 
does anyone know why?

I don't know the exact mechanism that is used to determine the java home, however, where does the bn directory sit? If it's in the jre directory, then that's the Java home and you shouldn't be messing with it.
 
This topic has 6 replies on 1 page.