Hi friends,

I have requirement i.e I want to call a java method from php code, for this i put some configurations in php.ini file

java.class.path = "C:\wamp\bin\php\php5.2.5\ext\JavaBridge.jar;C:\wamp\bin\php\Java\Classes"
java.home = "C:\Program Files\Java\jdk1.6.0;C:\Program Files\Java\jdk1.6.0\lib"
java.library = "C:\Program Files\Java\jre1.6.0\bin\client\jvm.dll"
java.library.path = "C:\wamp\bin\php\php5.2.5\ext;C:\Program Files\Java\jdk1.6.0\lib"

I am using JavaBridge.jar for java and php connection, for this i write one java class as like below

public class SampleStatic
{

public static void main(String args[])
{
System.out.println("saibaba");

}
public void sample(int arg)
{
	System.out.println("hai"+arg);
}

}

and my php code is like below
<?php
require_once("Java.inc");
$myj = new Java("SampleStatic");
echo 'saibaba'.$myj->sample(10);
?>

if i run the php file i got the below error like this

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new SampleStatic. Cause: java.lang.ClassNotFoundException: SampleStatic VM:

So if any one know the solution please tell to me

Thanks and Regards

swamy

    swamyvnvs;10947427 wrote:

    Hi friends,

    I have requirement i.e I want to call a java method from php code, for this i put some configurations in php.ini file

    Actually for a better solution is to look at the PHP Java Bridge. You can take a look at http://php-java-bridge.sourceforge.net/pjb/

    Thanks.

      Write a Reply...