From: <php...@li...> - 2006-11-13 10:14:13
|
Hi, is it possible to instanciate a PHP class from within a J2SE standalone application? I couldn't find any information about this on the php-java bridge website, it's all about web development. If not, does somebody know any possibility for this? regards, Verena |
From: <php...@li...> - 2006-11-13 18:30:43
|
Hi, > is it possible to instanciate a PHP class from > within a J2SE standalone > application? Yes, but that's deprecated. If you want to use Java we recommend to use a J2EE application server or servlet engine. For example Apache Geronimo or Sun's "Glassfish". > I couldn't find any information about > this on the php-java > bridge website, it's all about web development. Well, PHP is all about web development. IMHO PHP cannot be used in desktop applications; it has several limitations. It doesn't support threads and it doesn't have a real garbage collector. This means that long-running php applications will consume huge amounts of memory. The PHP reference counter cannot reclaim cycles for example. I know that there are some (IMHO insane) attempts to create desktop bindings, GTK bindings for example. But in practice these bindings don't really work well due to PHP's limitations. > If not, does somebody know any possibility for this? An old version (2.0.8) contained some MONO/NET GTK examples. Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-14 09:29:12
|
Am Montag, 13. November 2006 19:30 schrieb > > is it possible to instanciate a PHP class from > > within a J2SE standalone > > application? > > Yes, but that's deprecated. If you want to use Java we > recommend to use a J2EE application server or servlet > engine. For example Apache Geronimo or Sun's > "Glassfish". The problem with this solution is that in my opinion J2EE application don't scale well to the lower end. And the PHP application is ment for intranet use in small networks, so the overhead would be too much. > Well, PHP is all about web development. IMHO PHP > cannot be used in desktop applications; it has several > limitations. It doesn't support threads and it doesn't > have a real garbage collector. This means that > long-running php applications will consume huge > amounts of memory. The PHP reference counter cannot > reclaim cycles for example. I share your opinion here, too, maybe I should tell something about the background of my question. The PHP app has a strict object orientated design and a good separation of business logic, data access and presentation layer. We are thinking now about moving away from the web based model to a rich client. To speed things up we were hoping to reuse the PHP based business logic classes (at least for the first version, if the rich client proves its value, we would think about moving to Java completly for the long term). Since this actually would be a Java application which uses some PHP classes but runs inside the Java VM, the drawbacks of PHP you mentioned shouldn't be present in this solution. > I know that there are some (IMHO insane) attempts to > create desktop bindings, GTK bindings for example. But > in practice these bindings don't really work well due > to PHP's limitations. I had a look at those things and I share your opinion: not usable. > > If not, does somebody know any possibility for this? > > An old version (2.0.8) contained some MONO/NET GTK > examples. I'll have a look at this. Thanks for your answer, Verena |
From: <php...@li...> - 2006-11-14 18:30:31
|
Hi Verena, sorry for the misunderstanding. J2SE 1.6.0 will contain the necessary interfaces. For example the command: /opt/jdk1.6/bin/jrunscript -l php-intractive will start a Java VM with a PHP interpreter attached. On Linux you need to install java 6 and the php-java-bridge-devel package: rpm -i jdk-6-linux-i586.rpm rpm -i rpm -i php-java-bridge-devel-x.y.z-1.i386.rpm On Windows or Solaris you need to copy the JavaBridge.jar and the php-script.jar to the java extension dir. On Solaris this is /usr/java/packages/lib/ext/JavaBridge.jar and /usr/java/packages/lib/ext/php-script.jar For Java < 1.6.0 you also need the script-api.jar which is built automatically, if autoconf doesn't detect Java 6. The folder http://php-java-bridge.sourceforge.net/server/test/ contains a few tests. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-15 08:38:25
|
Hi Jost, this sounds great, I'll give it a try. Regards, Verena |
From: <php...@li...> - 2006-11-15 15:39:49
|
Am Dienstag, 14. November 2006 19:30 schrieb php...@li...: > For example the command: > > /opt/jdk1.6/bin/jrunscript -l php-intractive OK, what I did: - compiling the php-java-bridge source on my Suse Linux 10.1 x64 box from the tar.bz2 file. The used JDK was SUN JDK 1.5.0_x. - downloading Java 1.6.0 RC from SUNs website and installed the rpm - copied JavaBridge.jar php-script.jar script-api.jar to the JRE 6 extension dir - started /usr/java/jdk1.6.0/bin/jrunscript -l php-interactive Now I got a php-interactive> command prompt. Now I tried things like echo "test"; with and without the ;, with <? or <?php and so on, but always I got: php-interactive> echo "2"; script error: Could not evaluate script Is the problem that I compiled the bridge with a JDK 1.5 instead of 1.6? I tried 1.6 but there were some errors. If this might be the problem I'll post the compile errors here. I tried jrunscript with JavaScript as scripting language and this worked, so I guess the JDK is ok. Is some additional information needed? What could I do now? Regards, Verena |
From: <php...@li...> - 2006-11-15 16:51:32
|
Hi Verena, > > /opt/jdk1.6/bin/jrunscript -l php-intractive There are two ScriptEngines available, one is php-interactive and the other one is the "normal" php evaluator, which requires the "<?php" prefix. In any case, the log and error output appears in a file JavaBridge.log in the current directory. One can change this with the -Dphp.java.bridge.default_log_file="" option (empty string means log to stderr). The difference between "php-interactive" and php is that the former starts a Lisp/Scheme style repl, which in turn needs the java_closure() primitive to function properly. -- PHP was not designed for Lisp style evaluation, so "php-interactive" is pretty much experimental at the moment. > Now I got a php-interactive> command prompt. > Now I tried things like > echo "test"; > with and without the ;, with <? or <?php and so on, > but always I got: > php-interactive> echo "2"; > script error: Could not evaluate script You should find the reason in the JavaBridge.log. Most likely the java_closure() syntax is not available. It is exported from both, the pure PHP implementation "java/Java.php" and from the java.so extension. However, jrunscript -l php testfile.php should work as it doesn't need java_closure(). Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-16 09:31:12
|
Hi, thanks a lot for your help! > > Now I got a php-interactive> command prompt. > > Now I tried things like > > echo "test"; > > with and without the ;, with <? or <?php and so on, > > but always I got: > > php-interactive> echo "2"; > > script error: Could not evaluate script > > You should find the reason in the JavaBridge.log. Most > likely the java_closure() syntax is not available. It > is exported from both, the pure PHP implementation > "java/Java.php" and from the java.so extension. The problem was that I didn't had a php-cgi binary and so there was an IOException. I made a ln -s to the php5 binary. This solves the script error, but now there is the same error about the missing invoke method at interface javax.script.Invocable.invoke as when I tried to compile the test class. > jrunscript -l php testfile.php > > should work as it doesn't need java_closure(). actually nothing (visual) happens in that case. The file contains <?php echo "test"; ?> Neither any output to the console nor in the log file. Regards, Verena |
From: <php...@li...> - 2006-11-15 16:29:36
|
Am Dienstag, 14. November 2006 19:30 schrieb php...@li...: > The folder > http://php-java-bridge.sourceforge.net/server/test/ > contains a few tests. I tried http://php-java-bridge.sourceforge.net/server/test/HelloWorld.java: verena@dhcppc8:~/tmp> /usr/java/jdk1.6.0/bin/javac HelloWorld.java HelloWorld.java:27: cannot find symbol symbol : method invoke(java.lang.String,java.lang.Object[]) location: interface javax.script.Invocable String name = (String) ((Invocable)engine).invoke("java_get_server_name", new Object[]{}); ^ HelloWorld.java:32: cannot find symbol symbol : method invoke(java.lang.String,java.lang.Object[]) location: interface javax.script.Invocable name = (String) ((Invocable)engine).invoke("java_get_server_name", new Object[]{}); ^ 2 errors Did you develop this class with the RC of JDK1.6? Did the interface change? Regards, Verena |
From: <php...@li...> - 2006-11-15 17:03:43
|
Hi Verena, > Did you develop this class with the RC of JDK1.6? > Did the interface change? we've tested against the beta version of jdk1.6. There were some changes since then, so this might be the case, please see the ticket PR1597124 for details -> http://sourceforge.net/tracker/index.php?func=detail&aid=1597124&group_id=117793&atid=679233 Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-14 16:19:42
|
Am Montag, 13. November 2006 19:30 schrieb php...@li...: > > I couldn't find any information about > > this on the php-java > > bridge website, it's all about web development. [...] > > If not, does somebody know any possibility for this? > > An old version (2.0.8) contained some MONO/NET GTK > examples. I had a look there. But all I found was the other way round: a PHP class instanciating some MONO or JAVA classes. I'd like to write a Java class wich instanciates a PHP class. Regards, Verena |