As the error is saying, java is probably not installed on your system. You didn't specify an operating system but here is the output of java -version
in ubuntu without java:
x@y:~$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install <selected package>
As you can see it even tells you how to install java, the package I would suppose you need is default-jre
so you can go ahead and run sudo apt-get install default-jre
.
As to being able to run php java -version
that means you have a file named java
in the current working directory which runs php (for some reason?).
Of course you will have to research how to install java on your type of operating system, google is your friend here.