2

I set up a JavaBridge api over a Tomcat server. All right, it works well.

But I've got a specific need, I have Java classes to call from PHP and I haven't found any documentation about this.

Each java class is in a different file, do I have to include the files in a xml manifest or something like that ? Classes do have to be compiled or not ? (I think so but..)

Typically I would like to do :

<?php
    import com.test.Test;

    $obj=new Test();
?>

Thanks a lot.

EDIT (solved):

http://www.dsl.uow.edu.au/~sk33/php5java.htm

Tutorial very interesting.

  1. compile the java class and put it in a jar and thinking about the folders due to packages.
  2. Put the jar into the WEB-INF\lib folder
  3. Call the class
<?php
  require_once("java/Java.inc");
  //java_require("Test.jar"); //Deprecated !!!
  $obj=new Java("com.test.Test");
  echo $obj->getMessage();
?>
Oerd
  • 2,256
  • 1
  • 21
  • 35
flo360
  • 73
  • 1
  • 2
  • 6

1 Answers1

0

You need to do something like:

 <?php
    $obj = new Java("com.test.Test");
 ?>
bragboy
  • 34,892
  • 30
  • 114
  • 171