Page 1 of 1

Fatal error: Class 'Java' not found

Posted: Tue May 08, 2007 10:51 am
by Leo Hubert
Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi,

i'm getting this error "Fatal error: Class 'Java' not found",
while trying to execute the following php.

Code: Select all

<html>
<head>
<title>php program</title>
</head>

<body>


<?php
// get instance of Java class java.lang.System in PHP
$system = new Java('java.lang.System');

// demonstrate property access
echo 'Java version=' . $system->getProperty('java.version') . '<br />';
echo 'Java vendor=' . $system->getProperty('java.vendor') . '<br />';
echo 'OS=' . $system->getProperty('os.name') . ' ' .
             $system->getProperty('os.version') . ' on ' .
             $system->getProperty('os.arch') . ' <br />';

// java.util.Date example
$formatter = new Java('java.text.SimpleDateFormat',
                      "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");

echo $formatter->format(new Java('java.util.Date'));
?>


</body>
</html>
could someone help me with this???
thanks.


Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue May 08, 2007 10:57 am
by dhrosti
you need to include() or require() the class first, otherwise the script doesnt have anything to work with.

Posted: Tue May 08, 2007 11:33 am
by timvw
In this situation it's because the Java extension has not been loaded (http://be2.php.net/java)