Page 1 of 1

Help, nothing display with AWT jave code?

Posted: Thu Jun 13, 2002 12:22 am
by sqyphp
My architecture is apache + PHP, PHP was installed as CGI mode

I have tested two PHP java examples, one is

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

// demonstrate property access
print 'Java version='.$system->getProperty('java.version').' <br>';
print 'Java vendor=' .$system->getProperty('java.vendor').' <br>';
print '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");

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

This example works properly.

Another is,

<?php
// This example is only intented to be run as a CGI.

$frame = new Java('java.awt.Frame', 'PHP');
$button = new Java('java.awt.Button', 'Hello Java World!');

$frame->add('North', $button);
$frame->validate();
$frame->pack();
$frame->visible = True;

$thread = new Java('java.lang.Thread');
$thread->sleep(10000);

$frame->dispose();
?>

But nothing display, no error occur, return source is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>

What's wrong with the AWT example?

Posted: Thu Jun 13, 2002 2:59 am
by volka
are you requesting this script from a remote client?

Yes, I access with IE

Posted: Thu Jun 13, 2002 5:01 am
by sqyphp
Yes, I access with IE

Posted: Thu Jun 13, 2002 5:13 am
by volka
so where should the frame and button be created?
your php-script runs in a windowless process on the server.
Your browser(client) only gets the output of the script.