|
From: <php...@li...> - 2008-10-13 20:08:30
|
hello,
Find here enclose a code exemple :
<?
require_once 'Java.inc';
// créer une instance de la classe Java java.lang.System dans PHP
putenv("XAPPLRESDIR=/opt/matlab/X11/app-defaults");
putenv("LD_LIBRARY_PATH=".getenv('LD_LIBRARY_PATH').":/opt/matlab/sys/os/glnxa64/:/opt/matlab/bin/glnxa64/:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/native_threads:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/server:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64");
exec("export
LD_LIBRARY_PATH=".getenv('LD_LIBRARY_PATH').":/opt/matlab/sys/os/glnxa64/:/opt/matlab/bin/glnxa64/:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/native_threads:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/server:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64");
exec("export XAPPLRESDIR=/opt/matlab/X11/app-defaults");
define("XAPPLRESDIR","/opt/matlab/X11/app-defaults");
define("LD_LIBRARY_PATH",getenv('LD_LIBRARY_PATH').":/opt/matlab/sys/os/glnxa64/:/opt/matlab/bin/glnxa64/:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/native_threads:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/server:/opt/matlab/sys/java/jre/glnxa64/jre1.6.0/lib/amd64");
$test =
java_require("file:/home/bidsgui/java/bidsgui.jar;file:/opt/matlab/toolbox/javabuilder/jar/javabuilder.jar;file:/home/bidsgui/java/test_myplus.jar"
);
/* Create new magic object */
$thePlus = new Java( 'testMatlab' );
/* Compute plus */
$result = $thePlus->wrMyplus (1,2 );
print ( $result );
?>
This code is using java class exported from Matlab in a php script.
but this code does not work, because the environnement variable are not
recocgnise by javabuilder.jar.
regards
David
php...@li... a écrit :
> Hi David,
>
>
>> Well I'm starting using php-java-bridge under linux.
>>
>
> I assume that you don't want to use Java. The linux binary is a native binary and has been compiled against the standard library path, which is /usr/lib. However, I doubt that matlab will work with GNU Java.
>
> Please use a real Java implementation instead.
>
>
>
>> When I implement Matlab Java export in Java, there is no
>> problem, after
>> I have define LD_LIBRARY_PATH with "export".
>>
>
> Fine.
>
>
>
>
>> indicating that it does not find Matlab PATH.
>>
>
> Well, just start a real JVM and set the LD_LIBRARY_PATH before starting your Java application. After that you can call your app methods from PHP, as usual.
>
>
>
>> However, I try "export", php putenv function and
>> exec() without success.
>>
>
> I don't understand. There is no putenv() procedure in Java, so java("java.lang.System")->putenv(...) will almost certainly not work.
>
>
> Regards,
> Jost Boekemeier
>
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>
>
>
|