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
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: