|
From: <php...@li...> - 2008-03-04 13:24:35
|
Hi, I'm trying to get my php-java bridge working but without success. Php communicates well with Java but my problem is that i can't access (more precisely, don't know how to access) to a running object. How would I do to get an instance of this object ? To be more clear, an application is lauched with the java command. I want to access to some parameters to show them using Php, while the application is still running, doing some other treatment. Thanks for your precious help Thomas -- # !! brOl_oUilLe --> |
|
From: <php...@li...> - 2008-03-04 15:27:50
|
Please see the INSTALL.STANDALONE for details how to invoke methods within a running Java process.
__________________________________ Ihre erste Baustelle? Wissenswertes für Bastler und Hobby Handwerker. www.yahoo.de/clever
|
|
From: <php...@li...> - 2008-03-07 15:20:01
|
Hmm, well me again. Sorry to bother but i feel like a dumb. I can't get rid of my problem and i don't really get all the faces of how to use the bridge in the way i want to use it. Thanks for the various INSTALL files which i haven't seen at first. It helped me a bit though. What I understood is that the JavaBridgeRunner is the entry point of the bridge. But how do I use it. It seems that I have to open the socket myself? I am able to make my php communicates with my java class and get the runner but after then... I was actually thinking about using something like a stub on the php side, which would connect to another JVM where my Java object is already instanciated (something like RMI actually). Then I would have been able to catch my parameters through that socket. Am I completely wrong and should search in another direction or is it just that i missed something in the 'how to use' process? Would you mind explaining me what i got wrong? Thanks for your help 2008/3/4, php...@li... < php...@li...>: > > Please see the INSTALL.STANDALONE for details how to invoke methods within > a running Java process. > > > __________________________________ Ihre erste Baustelle? > Wissenswertes für Bastler und Hobby Handwerker. www.yahoo.de/clever > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > -- # !! brOl_oUilLe --> << bro...@gm... >> |
|
From: <php...@li...> - 2008-03-08 13:26:29
|
Hi,
> the entry point of the bridge. But how do I use it. It seems that I have to
With Runner.getRequiredInstance(). This allocates a Java continuation which has full access
to your Java objects.
Please see the INSTALL.STANDALONE document for details.
> I was actually thinking about using something like a stub on the php side,
> which would connect to another JVM where my Java object is already
> instanciated (something like RMI actually).
You could as well use RMI from within your Java continuation, please see the J2EE examples from
the source download folder.
But why don't you simply call into the Java continuation and use the objects already allocated by
your Java application?
Regards,
Jost Boekemeier
Lesen Sie Ihre E-Mails auf dem Handy.
www.yahoo.de/go
|
|
From: <php...@li...> - 2008-03-10 12:42:34
|
Hi,
> With Runner.getRequiredInstance(). This allocates a Java continuation
which has full access to your Java objects.
> Please see the INSTALL.STANDALONE document for details.
Ok, so here is what i have done, following the instructions given by
INSTALL.STANDALONE and INSTALL.J2EE
I have my very simple java application:
package app;
public class Main {
public static final String JAVABRIDGE_PORT="8091";
static final php.java.bridge.JavaBridgeRunner runner =
php.java.bridge.JavaBridgeRunner.getRequiredInstance(JAVABRIDGE_PORT);
private static int obj;
public static void main(String[] args) {
obj = new Integer(15);
System.out.println(getObj());
while(true);
}
public static int getObj() { return obj; }
}
I make a jar archive from it (phpjava.jar). The jar contains:
app/Main.class
META-INF/MANIFEST.MF
The Manifest is:
Manifest-Version: 1.0
Main-Class: app.Main
Created-By: 1.5.0
Class-Path: JavaBridge.jar
I put the archive into my deployment directory 'ext'. This directory
contains:
- java/Java.inc
- hello.php
- JavaBridge.jar
- phpjava.jar
According to the manifest of JavaBridge.jar, I have also put in 'ext' (just
in case):
- php-script.jar
- script-api.jar
Here is the php script:
<?php
require_once("java/Java.inc");
java_require("phpjava.jar");
$myClass = new java("app.Main");
$obj = $myClass->getObj();
echo $obj;
?>
I launch the JavaBridge.jar by right-clicking on it and 'execute with
java...' and select the socket.
I execute in a shell: java -jar phpjava.jar
The value of 15 appears and then the application continues running because
of the while(true) loop.
I try to connect through http://localhost:8091/hello.php
The value of 0 appears.
The VMbridge.log warns me that the port is already being used.
Meaning that with php, it launches another instance of my Main.class
What am I missing ? For me, the "new java(app.Main);" line in the php script
is not the correct one if I want to get the already allocated objects.
Is 'runner' the variable I should use from php or is it a variable used by
the bridge ?
Which kind of methods can I call to access my allocated objects ?
> But why don't you simply call into the Java continuation and use the
objects already allocated by your Java application?
I would love to :)
Thanks for your help
Regards,
--
# !! brOl_oUilLe -->
|
|
From: <php...@li...> - 2008-03-10 13:20:12
|
Hi,
> public static void main(String[] args) {
> obj = new Integer(15);
> System.out.println(getObj());
> while(true);
> }
> public static int getObj() { return obj; }
> }
Okay. But you may want to use Thread.sleep() instead of the while(true); loop. :)
> I make a jar archive from it (phpjava.jar). The jar contains:
> Main-Class: app.Main
> Class-Path: JavaBridge.jar
Okay.
Next you can run a PHP script as follows:
<?php require("http://localhost8091/JavaBridge/java/Java.inc");
$myClass = new java("app.Main");
echo $myClass->getObj();
?>
> I put the archive into my deployment directory 'ext'. This directory
> contains:
> - java/Java.inc
> - hello.php
> - JavaBridge.jar
> - phpjava.jar
I don't understand why this is necessary.
> According to the manifest of JavaBridge.jar, I have also put in 'ext' (just
> in case):
> - php-script.jar
> - script-api.jar
No. These are the JSR223 bindings.
> Here is the php script:
> <?php
> require_once("java/Java.inc");
> java_require("phpjava.jar");
> $myClass = new java("app.Main");
> $obj = $myClass->getObj();
> echo $obj;
> ?>
No. The above script connects to the wrong application (if any). The java_require() is not
necessary either, your application already knows about app.Main.
> I launch the JavaBridge.jar by right-clicking on it and 'execute with
No. You have already started your application.
Regards,
Jost Boekemeier
Lesen Sie Ihre E-Mails jetzt einfach von unterwegs.
www.yahoo.de/go
|
|
From: <php...@li...> - 2008-03-10 13:53:19
|
Hi,
Ah Thanks a lot :)
It finally works. My mistakes were :
require("http://localhost8091/JavaBridge/java/Java.inc");
The 'localhost' link is effectively important
launching the JavaBridge.jar
Which of course was already launched
By clearing my php script according to your advice, it now works perfectly
:)
>> I put the archive into my deployment directory 'ext'. This directory
contains:
>> - java/Java.inc
>> - hello.php
>> - JavaBridge.jar
>> - phpjava.jar
> I don't understand why this is necessary.
It was just to be sure that the correct scripts were called.
Thanks again and sorry for my low understanding :p
Tom
--
# !! brOl_oUilLe -->
|
|
From: <php...@li...> - 2008-03-11 10:29:18
|
Hi, I'm back with my problems :) Let's consider my launched application. There is the 'main' function which is 'static' and which creates other objects, from other classes, to be used. Of course these objects are not necessarily attributes of the main class, o/w they would be 'static' as well, wouldn't they? Is there a way to get access to these objects if they are instanciated in the main itself? rgds, Tom -- # !! brOl_oUilLe --> |
|
From: <php...@li...> - 2008-03-11 11:27:11
|
Hi,
Java has certain mechanisms which allow one to discover objects. Since all object trees are at
least referenced by a thread (otherwise they'd be garbage collected), I'm sure you find a way how
to create / discover your object graphs.
Unfortunately this is outside of the scope of the PHP/Java Bridge, but you'll find more
information in a Java related forum.
Regards,
Jost Boekemeier
Machen Sie Yahoo! zu Ihrer Startseite. Los geht's:
http://de.yahoo.com/set
|
|
From: <php...@li...> - 2008-03-11 11:42:22
|
Hi, Hmm, ok, I will have look at this. Thanks for the suggestion :) Rgds Tom -- # !! brOl_oUilLe --> |