Home arrow PHP arrow Page 2 - Using PHP with Java

Getting Started - PHP

You probably already know that PHP comes with extensions for awide variety of different technologies. But did you know that you couldhook PHP up to Java, and use Java classes and Java Beans from withinyour PHP scripts? If this is news to you, keep reading.

TABLE OF CONTENTS:
  1. Using PHP with Java
  2. Getting Started
  3. Rank And File
  4. A Custom Job
  5. Passing The Parcel
  6. An Exceptionally Clever Cow
  7. Beanie Baby
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 17
April 03, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
PHP doesn't come with Java support turned on by default, so you'll need to recompile it to enable this support. You can do this by adding the "--with-java" compile-time parameter to the PHP "configure" script. Note that you'll also need a copy of the latest JDK - you can get this from http://java.sun.com/ (the examples in this article use version 1.3.0 of the JDK).

If you're using Windows, you've already got a pre-built Java extension with your PHP distribution - all you need to do is enable it. First, make sure that your system's PATH variable includes the path to the JDK - this can easily be accomplished by altering the PATH variable in your "autoexec.bat" file.

Next, pop open the "php.ini" configuration file, and skip over all the cryptic configuration commands to the "Java" section. There, set values for the following variables:

java.library - this refers to the location of the Java Virtual Machine file (jvm.dll), usually located in the JRE directory;

java.library.path - this refers to the location of PHP's Java extension;

java.home - this refers to the JDK's "bin" directory;

java.class.path - this refers to the Java CLASSPATH, which contains your custom Java classes. You should make sure that this variable always includes the location of the "php_java.jar" file (usually the /java/ directory)

While you're editing this file, also drop by the "Windows Extensions" section of "php.ini" and uncomment the "php_java.dll" extension.

Finally, check to make sure that the file "php_java.dll" is in the /extensions/ sub-directory, restart your Web server, and you're ready to roll!

 
 
>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap

Dev Shed Tutorial Topics: