2

Possible Duplicate:
Troubleshooting ClassNotFoundException when using PHP/Java bridge

Can anyone please explain me about the PHP/Java Bridge installation.

I already installed bridge in my system.

This is my HelloWorld.java code :

import javax.swing.JOptionPane;

public class HelloWorld
{
    public static final String JAVABRIDGE_PORT="8081";
    static final php.java.bridge.JavaBridgeRunner runner = 
                 php.java.bridge.JavaBridgeRunner.getInstance(JAVABRIDGE_PORT);

    public static void main(String args[]) throws Exception
    {
        runner.waitFor();
        System.exit(0);
    }
    public void hello(String args[]) throws Exception
    {
        JOptionPane.showMessageDialog(null, "hello " + args[0]);
    }
}

This is my HelloWorld.php code:

<?php 
    require_once("http://localhost:8081/JavaBridge/java/Java.inc");

    $world = new java("HelloWorld");
    echo $world->hello(array("from PHP"));
?>

While calling Java class from php, it is not working and it is showing the below error:

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new HelloWorld. Cause: java.lang.ClassNotFoundException: HelloWorld VM: 1.5.0_01@http://java.sun.com/" at: #-31 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438) #-30 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284) #-29 java.lang.ClassLoader.loadClassInternal(Unknown Source) #-28 java.lang.Class.forName0(Native Method) #-27 java.lang.Class.forName(Unknown Source) #-26 php.java.bridge.Util.classForName(Util.java:1518) #-25 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-24 php.java.bridge.Request.handleRequest(Request.java:458) #-23 php.java.bridge.Request.handleOneRequest(Request.java:510) #-22 php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202) #-21 php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250) #-20 php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261) #-19 javax.servlet.http.HttpServlet.service(HttpS in http://localhost:8081/JavaBridge/java/Java.inc on line 195

Can you please anyone help me on this.

Thanks in advance.

0

1 Answer 1

0

I am unfamiliar with the package you are trying to use but it looks like you need to give the full path to your class. That is java/lang/ClassNotFoundException for example for the Java Exception that is being thrown and probably something like me/mypackage/HelloWordl for the class you are trying to create.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.