As a web developer PHP has always been top of my list when it comes to programming but just recently with my studies Java has been my main language and as I have come to love Java I looked into ways of using both PHP and Java together.
While searching the internet I found a few different solutions to this, you are able to recompile PHP with java support on both windows and Linux but the easiest solution I found for the windows operating system was Java Bridge, combined with WAMP (Windows Apache MySql and PHP) I was already to go in a matter of minutes.
First you will need to download the Java Bridge files http://sourceforge.net/project/showfiles.php?group_id=117793
and extract them into the root of your WAMP web server, usually the www directory.
- Navigate to www/WEB-INF/lib/
- run JavaBridge.jar
- Select SERVLET_LOCAL:8080
Now everything is ready, to test everything worked run the test.php file that you extracted and scroll down to the bottom of the page, here you should be able to see all the details about the java version installed.
If you have any problems make sure you do not have the php_java extension enabled within WAMP and make sure your server restarted, (WAMP usually does this for you when disabling / enabling extensions). If it is still not working feel free to post your problems below and I will try to help where possible.
When you start writing your own programs you will need to include the java/Java.inc file along with any other classes you intend to use such as java.lang.String.
I look forward to people posting some interesting examples of code they have written using both Java and PHP or tasks you wish to accomplish using Java and PHP. Below are a few examples to get your going, have fun.
$text = new Java("java.lang.String", "Hello World") . "\n"; echo $text; $date = new Java("java.util.Date"); echo $date->toString() . "\n"; $os = new JavaClass("java.lang.System"); echo "Operating System: " . $os->getProperty("os.name") . "\n"; $math = new JavaClass("java.lang.Math"); echo "PI: ".$math->PI."\n"; ?>
I started to write all backed end classes using java, when i configured all the javabridge & php_java.dll files into the respective directories and changed the php.ini configurations too. After completion of all the configuration i restarted my wamp server suddenly one popup comes with an warning message like "PHP Startup : Invalid library (maybe not a PHP library) 'php_java.dll". I tried to find the "java-x86-windows.dll" file in the javabridge.war file but i could not found that. If you have that file please send it to my email id.
I do not understand points :
I have wamp and tomcat running. unable to understand where to put "JavaBridge.jar" and run it?