Categories
Coding Java PHP Zend Framework

PHP Java Bridge vs. Zend Platform Java Bridge

A long time ago I posted some instructions on installing PHP/Java Bridge on Ubuntu and that post is getting quite a few reads, so I figured I’d post a follow up on how it was used.

Over the last year I had been using a Java Bridge from a Zend Framework application to access a Java only API.  And really, between the two bridges there are no differences.  They both work identical, they both work great.  Would I pay Zend for Zend Platform’s Enterprise license? No.  Why? Because both bridges perform the same.  The only differences are:

  1. Zend’s Java bridge already has a function called java_require and the open source PHP/Java Bridge needs you to include a file.
  2. PHP/Java Bridge has a java_cast function, and you need it.  Zend’s Java Bridge does not have, or need this.

With these two differences all you need is a little code in your bootstrap (or somewhere else useful) to cover them and all is golden. Your app should work with both Java Bridges without any issue.

/* no java_require() include the java.inc for PHP/Java Bridge */
if ( ! function_exists('java_require') ) {
    include "java/Java.inc";
}

/* declare this, it doesn't exist with Zend Java, but is needed for PHP/Java Bridge */
if ( ! function_exists('java_cast')) {
    function java_cast($whatever) {
        return $whatever;
    }
}

There’s probably a more graceful way of checking and doing this but that’s it, and it’s worked on a multi tiered build environment for over a year now.

Categories
Java

Google Wave Preview – Holy Shit

I think Google has managed to create the most powerful multi-platform collaborative tool ever known to man.

This demo is long and very detailed but Google Wave implements so many different tools and concepts into one single point — it’s jaw dropping.

The craziest part of it is the near real-time updates, as well as the fact that multiple users can edit the same documents, with complete playback of changes

It implements these tools (and this is a short list):

  • Email
  • Instant Messaging
  • Image Sharing/Gallery
  • Wiki
  • Searching
  • Document Creation
  • Games
  • Maps
  • … and more

On these platforms:

  • Your web browser
  • Your blog
  • Your smart phone
  • Your [insert whatever here]

Watch the Google Wave Preview.

Categories
Coding Java

Google I/O 2008

I had the pleasure of attending Google I/O in San Francisco this year.  I’m only getting to posting about it now because work has been far too insane for me to even stop and think about all the glorious things I heard about during the conference.

In fact, I still find it hard to come up with any one outstanding part of the conference.  It was all so awesome, and all so in depth.

If there is anything that I brought out of it, it’s a desire to learn more Java and figure out some ideas to deal with GWT and Android.  Those are two pretty hot topics in my mind right now.

I was also impressed with the Google Earth and Google Maps API integration.  That’s a pretty sweet package right there.  I love maps, and man making maps with Google is fun.

Hopefully I’ll be able to put together some cool things for work in the near future.  I’ve got one project requiring maps and travel data right now, so we’ll see what that brings.

I also have a desire to actually figure out a Rubiks Cube.  Thanks Google, it was a blast.  See you next year, I hope.

Categories
Coding Java Linux

Eclipse and Ubuntu 8.04

I was having some trouble running Eclipse 3.3 Europa on Hardy Heron.  It was unstable, crashing a lot, and hogging way more ram than it normally hogs.

Then I realized what I’d forgotten to do on this fresh install.  I forgot to simply ‘sudo update-java-alternatives -s java-6-sun’ and voila, it works like a charm.

Eclipse doesn’t work well with the gjc java (the ‘free’ and default) Hopefully this little thing won’t be an issue in the future when sun java 7 (open java) is ready to rock the free world.

Categories
Coding Java Linux PHP

Installing PHP Java Bridge on Ubuntu

Source Install

First, make sure all php packages are updated — if you update PHP after installing this, it will likely segfault.

For the purpose of this, I’m using Ubuntu 7.10, and Java 6 (sun-java6)


First, get the build essential, as well as php5-dev, sun java and automake

# apt-get install build-essential php5-dev sun-java6-jre \
    sun-java6-jdk sun-java6-source automake

Second, get the PHP/Java bridge source.

# cd /usr/src
# wget http://internap.dl.sourceforge.net/sourceforge/php-java-bridge/php-java-bridge_5.2.0.tar.gz
# tar xzfv php-java-bridge_5.2.0.tar.gz

And, install.

# cd /usr/src/php-java-bridge-5.2.0
# phpize
# ./configure --with-java=/usr/lib/jvm/java-6-sun-1.6.0.03,/usr/lib/jvm/java-6-sun-1.6.0.03
# make
# chmod +x install.sh
# ./install.sh

Answering the questions for the install script is fairly simple. It looks for some tomcat stuff for the servlet portion of the Java Bridge, but we won’t be using it.

Copy *.inc to someplace it can be found.

# mkdir /usr/share/php/java
# cp *.inc /usr/share/php/java

Testing,

# php test.php

By default, java is only enabled in the command line php; to enable it in the global instances of php, edit the php.ini file and add the extension.

;; java.ini: Activate the PHP/Java extension

;; zend_extension = "/path/to/java.so"
extension = java.so

;; If you have installed the java-servlet.ini leave this file alone,
;; edit the servlet or standalone ini file.  Otherwise uncomment the
;; following java section and one of the following options:
[java]

There are no other options required. Make sure the java.hosts and java.servlet are disabled. If logging is desired, that’s another story.