1

I am working on windows. I am running PHP (5.1.3) scripts on Tomcat using PHP/Java bridge. Here is my simple code

//test.php
<?php
require_once("java\Java.inc");
$systemInfo = new Java("Test");
print $systemInfo->foo();
?>

//test.java
class Test
{
 public void foo()
 {
  System.out.println("hello php");
 }
}

Test.class is in the same folder as test.php. But the php file is not able to locate the test class and I get the following error -

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new Test. 

If I use a standard class like below. It works -

<?php
require_once("java\Java.inc");
$systemInfo = new Java("java.lang.System");
print "Total seconds since January 1, 1970: 
".$systemInfo->currentTimeMillis();
?>

What should I do?

1)Should I copy my class to the standard location where all Java classes are kept. (What is this location?)

2) Do some changes in the php.ini file

1
  • 1
    Packaging error? Can you post Test.java, or at least it's package and signatures? Commented Apr 29, 2010 at 5:56

1 Answer 1

1

have you set the following attribute in php.ini?

[java]
java.class.path="/path/to/folder/containing/Test"

Also, use a package (like com.jack.Test) when creating classes. It is just convention, but you'll find that it makes a lot of sense once you're creating entire projects

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

1 Comment

I changed the php.ini like you said...I am still getting the same error

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.