How can I execute a Java program within a php script?

后端 未结 4 387
慢半拍i
慢半拍i 2021-01-02 22:02

I am writing a simple web upload script. The goal is to upload a file using php, and then calling a java program to process this file.
I have done the work for uploading

4条回答
  •  借酒劲吻你
    2021-01-02 23:08

    I dont realy know, but i came a cross PHP-JAVA bridge maybe it can help

    http://php-java-bridge.sourceforge.net/pjb/

    Update:

    I tested this with Jasper Reports, and it is working really nice. It will allow you to Extend Java classes with PHP or just use Java class lik it was PHP.

    use java\lang\String as JString;
    require_once("javabridge/java/Java.inc");
    
    class String extends JString {
        function toString () {
            return "hello " . parent::toString();
        }
    }
    $str = new String("Java");
    echo $str->toString();
    

    or

    $temp = new Java('java.sql.Timestamp');
    $javaObject = $temp->valueOf('2007-12-31 0:0:0');
    
    
    $params = new Java("java.util.HashMap");
    $params->put("text", "This is a test string");
    $params->put("date",$javaObject);
    

    More examples: http://php-java-bridge.sourceforge.net/pjb/FAQ.html

提交回复
热议问题