If you are using Linux/Unix/Mac OS X:
Try this:
$ which java
Should output the exact location.
After that, you can set JAVA_HOME environment variable yourself.
In my computer (Mac OS X – Snow Leopard):
$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Nov 7 07:59 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
If you are using Windows:
c:> for %i in (java.exe) do @echo. %~$PATH:i
Windows > Start > cmd >
C:> for %i in (javac.exe) do @echo. %~$PATH:i
If you have a JDK installed, the Path is displayed,
for example: C:Program FilesJavajdk1.6.0_30binjavac.exe