How to call jar files from PHP?

I know this question is not new, but I am posting it by going through enough googling around.

I have a jar file that I do not control. I mean, I did not write a Java class there, and all I know is that it has a class called "hist" in it that takes two arrays and produces the result. Now I have to use PHP to call this class "hist" in a jar file called "histvol.jar". I installed PHP / Java Bridge and it is installed correctly.
But I do not understand how to name this jar file in PHP and where to place this jar file.

This is what I did:

  • Installed tomcat and php-javabridge
  • Posted by jarfile "histvol.jar" in Tomcat / webapps / JavaBridgeTemplate621 / webinf / lib /
  • Went to xampp / htdocs and created a file called testjava.php

<?php require_once("http://localhost:8080/JavaBridgeTemplate621/java/Java.inc"); $System = java("java.lang.System"); $myclass=java("histvol"); echo $System->getProperties(); ?> 
Exception expected

Class not found , because I do not call it anywhere in PHP, but what should I call it?
I'm lost, please help (I do not know the word Java).

+4
source share
1 answer

Ok, I got it, finally, I just had to do it: -

 $myclass=new java("histvolone.histvol"); 

instead

 $myclass=new java("histvol"); 

It worked!

+4
source

All Articles