douxiapi4381 2011-02-25 23:17
浏览 56
已采纳

PHP获取数据或与正在运行的Java进程交互。 (我认为不同于PHP / Java桥)

I have an apache2 webserver with php installed and working. I am wondering if there is any way I can get a PHP script to access a Java program that is constantly running, mostly to just get information that the process keeps track of. The Java program is not a webapp or running within the apache server. It is a separate program.

Ive been looking into PHP/Java Bridge systems, and all they seem to do is let you run Java programs from PHP and vice-a-versa, which is not what I need. I can think of a way to do this via a web service and SOAP running on localhost, but if there is a way to avoid this and I can gain direct access to the Java program, I could get my webapp to run much faster.

The Java app that I am trying to "talk to" is a program that I wrote so I have access to the source code to make the necessary changes if something within the Java program needs to be set up.

Thanks in advance, I've been looking all over for something like this.

  • 写回答

4条回答 默认 最新

  • duancuisan2503 2011-02-27 15:10
    关注

    PHP/Java Bridges let you call a running Java program from PHP.

    Read: http://en.wikipedia.org/wiki/PHP/Java_Bridge

    Read: http://php-java-bridge.sourceforge.net/pjb/desktop-apps.php

    The bridges actually use local socket communication, from the faq:

    <?php
        include_once("Java.inc");
    
    $i1 = new Java("your.class", "1");
    $i2 = new Java("your.class", "2");
    $i3 = $i1->add($i2);
    echo $i3->toString() . "
    ";
    ?>
    

    See Java.inc. And edit your java code to contain the following line:

    static final php.java.bridge.JavaBridgeRunner runner = php.java.bridge.JavaBridgeRunner.getInstance("9267");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号