A long time before .NET was even conceived, and even before COM was conceived, Sun's Java project was well underway. With the goal of producing a language that worked anywhere, from small appliances to multiple-CPU servers, Java has become a widespread language offering arguably the most complete set of functionality of any language. Furthermore, it has a powerful virtual machine (VM) system that enables the same binary code to be executed on multiple platforms - wherever there is a Java Virtual Machine (JVM), the binary code can run.
When used with PHP, there are three distinct possibilities: executing Java code line by line, loading and utilising your own Java classes, and creating Swing GUIs. Swing is the name of Java's lightweight windowing toolkit - more on that later.
Installation of Java is quite difficult, simply because Java itself is quite a complicated beast. Java and PHP combined should work on all platforms where Java by itself and PHP work by themselves.
It is important to note that using Java through PHP is largely the same as using Java directly - if you're not a Java programmer, this section will not help much, as there is not space to teach Java and PHP here.
Please note: you will need to install a PHP/Java bridge to use Java inside PHP. See http://php-java-bridge.sourceforge.net/pjb/how_it_works.php for more information.
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!
Next chapter: Basic Java use >>
Previous chapter: Microsoft .NET
Jump to:
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.