JAVA_HOME issue with Beta release of Openfire

I need help. I have VPS with Cpanel installed. Now I want to install Openfire on it. The below Beta release is mentioned as it include JAVA & JRE however I am getting below error.

I got the same error when I have tried for 3.6.4.1 stable release as well.

root@ns1 [~]# rpm -ivh openfire-3.7.0.beta-1.i386.rpm
Preparing… ########################################### [100%]
1:openfire ########################################### [100%]
Error: JAVA_HOME is not defined correctly.
Can not sure execute /usr/local/jdk/bin/java.
root@ns1 [~]#

Then I tried to install jre-6u22-linux-i586.bin mentioning /root/jre/bin/java in /etc/bashrc… some how I am getting nohup message as permission denied.

Not able to bring the first page of openfire installation at http://URL:9090

Should I install openfire as Root or as normal user.

Please help.

root@ns1 [/etc/init.d]# ./openfire start
Error: JAVA_HOME is not defined correctly.
Can not sure execute /opt/openfire/jre/bin/java/bin/java.
root@ns1 [/etc/init.d]# vi openfire
root@ns1 [/etc/init.d]# echo $JAVA_HOME
/opt/openfire/jre/bin/java
root@ns1 [/etc/init.d]# export JAVA_HOME=/opt/openfire/jre/
root@ns1 [/etc/init.d]# ./openfire start
Openfire is already running. Remove /var/run/openfire.pid if you know this to be untrue.
root@ns1 [/etc/init.d]# ./openfire stop
Shutting down openfire: ./openfire: line 142: kill: (29270) - No such process

root@ns1 [/etc/init.d]# ./openfire stop
Shutting down openfire: ./openfire: line 142: kill: (29270) - No such process

root@ns1 [/etc/init.d]# ./openfire start
Openfire is already running. Remove /var/run/openfire.pid if you know this to be untrue.
root@ns1 [/etc/init.d]#

root@ns1 [/opt/openfire/bin]# ./openfire.sh
ls: /usr/java/j*: No such file or directory
Openfire 3.7.0 Beta [Oct 23, 2010 11:27:25 PM]
Admin console listening at:
http://URL:9090
https://URL:9091

This is working & I can login in Admin… How can I make Openfire to run & be up always

You may want to add the “export JAVA_HOME=/opt/openfire/jre/” line to /etc/rc.d/init.d/openfire as this seems to help.