Problems in running java -version command


hi all

i am now using CentOS 5 ; Nagios 3.0 ; Java 1.6.0_03

i want to confirm the java version and printout to the nagios web interface
i did add the JAVA_HOME and PATH env to the profile under the root home diretory.
i got the right version by command (nagios user)

so i wrote a very simple script(check_java) like

java -version
exit 0

add a command in command.cfg
define command{
command_name check_java
command_line $USER1$/check_java

$USER1$ macro refers to /usr/local/nagios/libexec
and then changed the nagios host&service confige file

but i finally got the result that is java 1.4.0 with gnu runtime through the web interface

when i changed the script by add the full path before java
like /usr/java/jdk1.6.0_03/bin/java -version

it prints out (null) on the status information

could anybody tell me what i am missing?

thank you in advance.