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();
?>
1

1 Answer 1

0

You need to do something like:

 <?php
    $obj = new Java("com.test.Test");
 ?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.