home forums resources search newsjoinmembers: 5241
Joomla Wordpress Drupal Fireorb Flash Java PHP Ruby Windows
 videos
 articles
 blogs
 comments
 downloads
sitemap
a Visitor posted on: Tue, 2007-02-27 07:00.

Get php running correctly for command line php only
and get java running too so you can compile. I used
jdk 1.5.0_11 and php 5.2.0

Download JavaBridge 4.0.1 and extract the JavaBridge.war

from the .war extract JavaBridge.jar to a folder
on your box.

in that folder do:
java -jar JavaBridge.jar SERVLET:9090

which starts up a server for you.

then use:

import java.util.*;

import java.text.*;

import java.math.*;

public class Hello {

public static void main(String[] args) {

int i; // Do nothing

}

public String SayHello () {

Date today = new Date();

return "Hello Geek, today is " + today;

}

public int SayNumber () {

int mynum = 0;

for (int i=1; i

mynum =+ (int)(Math.random()*100);

}

return mynum;

}

}

and compile to another folder. I used
C:\Documents and Settings\root

Then code a php file:

<?php

require_once("http://localhost:9090/JavaBridge/java/Java.inc");
try {
java_require("C:\\Documents and Settings\\root\\");
$obj = new Java("Hello");
$output $obj->SayHello();
echo 
java_values($output) . "\n";
$output $obj->SayNumber();
echo 
java_values($output) . "\n";
@
java_reset();
       } catch(
JavaException $ex) { 
   
$exStr java_cast($ex"string"); 
   echo 
"Exception occured; mixed trace: $exStr\n"
   
$trace = new java("java.io.ByteArrayOutputStream"); 
   
$ex->printStackTrace(new java("java.io.PrintStream"$trace)); 
   print 
"java stack trace: $trace\n"


?>

have fun.

b.t.w, the Tomcat server runs this ok too on the 8080
port (when you deploy the .war), but I wanted to try command line and pure the java server only.

It works w/o the dll stuff since there can be
problems between PHP and the dll versioning.

Reply

required
How to use html
Verify comment authorship
Captcha Image: you will need to recognize the text in it.
required
Please type in the letters/numbers that are shown in the image above.
 

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top