I know this question is not new but I am posting this after going through enough googling around.
I have a jar file which I don’t control. I mean I have not written the Java class in there and all I know is that there is a class named “hist” in it which takes two arrays and gives out the output. Now I have to use PHP to call this class “hist” in the jar file named “histvol.jar”. I have installed the PHP/Java Bridge and it is installed correctly.
But I don’t understand how to call this jar file in PHP and where to place this jar file.
This is what I did:
- Installed tomcat and php-javabridge
- Placed the jarfile “histvol.jar” under Tomcat/webapps/JavaBridgeTemplate621/webinf/lib/
- Went to xampp/htdocs and created a file named testjava.php
<?php
require_once("http://localhost:8080/JavaBridgeTemplate621/java/Java.inc");
$System = java("java.lang.System");
$myclass=java("histvol");
echo $System->getProperties();
?>
Class not found exception is expected because I am not calling it anywhere in PHP, but how do I call it?
I am lost, please help (I don’t know a word of Java).
Ok I got it finally, I just had to do this:-
instead of
It worked !