2

I have setup php/java bridge followed this and its working fine.

but the problem is i am unable to run a java class file in my php code.

my class file test.java is as follow

  package recommander;
  public class test
  {
     public static void main(String[] args) 
      {
          System.out.println("good");

      }
  }

and my php file as below

 <?php 
    require_once("http://localhost:8080/JavaBridge/java/Java.inc");
    $System = java("java.lang.System");
    echo $System->getProperties();
    exec("java test", $output);
    print_r($output);
?>

But when i run this php file it gives me an empty Array with following error-

Error: Could not find or load main class test

Need help.

1 Answer 1

1

The error you're getting is because you're trying to compile an un-compiled Java file.

Make sure you compile the test.java file in Terminal/Command Line by:

javac test.java

and then try compiling the new test.class file:

exec("java test", $output);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.