0
package test;

public class HelloWorld {
    public static final String JAVABRIDGE_PORT = "8080";
    static final php.java.bridge.JavaBridgeRunner runner = php.java.bridge.JavaBridgeRunner
            .getInstance(JAVABRIDGE_PORT);

    public static void main(String args[]) throws Exception {
        runner.waitFor();
    }
}

<?php require_once("/path/to/Java.inc");
$hello_world = new java("test.HelloWorld");
?>

I know the code above can create a HelloWorld instance.

But what if the constructor of HelloWorld.java has some parameters?How to write the php code?

1
  • 2
    $hello_world = new java("test.HelloWorld",$parameter0,$parameter1); Commented Mar 28, 2016 at 11:53

1 Answer 1

0

here is my code,hope this can help you a bit.

php file:

**<?php require_once("C:/jetty-distribution-9.3.7.v20160115/webapps/JavaBridge/java/Java.inc");
$world = new java("HelloWorld");
echo $world->hello(array("from PHP"));
?>**

here $world is my object and you can pass the parameter of java in last line.

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.