10 tips for PHP scripts: Integrate with existing Java applications
Takeaway: With PHP you can invoke methods of existing Java objects, which lets you integrate PHP into existing Java-based applications. Find out how.
By Julie Meloni(2/6/01)
Another fancy bit of PHP functionality is its ability to invoke methods of existing Java objects, letting you integrate PHP into existing Java-based applications. This ability is pretty snazzy if you're pushing PHP in your workplace and the answer you get is, "But everything's Java here."
To utilize this functionality, you need to have a Java Virtual Machine (JVM) installed on the server. If you install (or have installed) JDKs from Sun, Kaffe, IBM, or Blackdown, you'll be up to speed.
When you configure PHP, you'll need to add --with-java to the configuration directives, then modify some elements of your php.ini file. The php.ini modifications are usually along the lines of adding the following:
[Java]
java.library.path=/path/to/library
java.class.path=/classpath/
extension_dir=/path/to/extensions
extension=libphp_java.so
Please note, however, that these modifications depend on your type of installation. You should read the README in the ext/java directory in your PHP installation directory to learn more about configuring for Java functionality.
Here's a very simple example of a PHP script creating a new Java object. The script will then access and print to the screen certain Java properties. It's about as exciting as the COM example, but it gives you an idea of the possibilities.
<?
$system = new Java("java.lang.System");
echo "<P>Java version = " . $system->getProperty("java.version") . "<br>";
echo "Java vendor = " . $system->getProperty("java.vendor") . "</p>";
?>
If you have Java knowledge, by all means jump in and help the developers with this project. These types of integration capabilities will be key in the future growth and acceptance of PHP, so the more people working on these types of things, the better.
Julie Meloni is the technical director at i2i Interactive and is an avowed proponent of Linux and the open source community. A regular contribtor to CNET Builder.com, she has written a few books on PHP and other technologies.
White Papers, Webcasts, and Downloads
- Critical Connections: Leveraging Technology to Improve Healthcare Qwest Communications The American Recovery and Reinvestment Act allocates more than $20 billion ... Download Now
- Webinar: Best Practices for Application Virtualization with AdminStudio Flexera Software IT professionals, are you considering a move to Microsoft� App-V?? Watch ... Download Now
- Live Webcast: Oracle Business Intelligence for Midsize Companies: More Than Just Pretty Dashboards Oracle Oracle's Business Intelligence solutions are widely recognized as market ... Download Now
- Top 7 Things You Should Know About Activation and Genuine Windows Microsoft As an IT Pro, you should be aware that volume activation is a required ... Download Now
- The Three Ps of Evaluating Managed Network Services Qwest Communications To reduce costs and keep IT resources focused on the core business, more ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET