Thursday, May 15, 2008

Eclipse, Spring, Red5 on Ubuntu

This is a log of my attempts to set up a Flash streaming server on Ubuntu 7.10 Server.

First I want to mention that I hate Java developers on a very personal level. Their mediocre mental facilities and sheep like tendencies is not an excuse. Java is the cancerous tumor on the ass of the programming world. The Java ideology is blindly idiotic even to the most simple minded among us (or so you would think.) It is rooted in the notion that you can reduce the number of mistakes (bugs) in a piece of software by making the language extremely verbose. The saga of the installation process for these tools is a testament in itself of the fallacy of this position. Notwithstanding the blindly obvious fact that we all know, after all, that verbose language leads to less mistakes. Right? Do you make more mistakes when you are writing a paragraph for a research paper, or a page of dense legal language? Besides this, which one is easier for an author to write? Which one is easier for someone whose second language is English? Enough said.

Unfortunatly, the simple minded fell for Sun's propaganda back in the 90s. Therefore we're stuck with this bastard child. Ironically, Red5 will eventually make Java irrelavent (by opening the market to alternative FMS implementations.) It is, after all, essentially building a technology which was designed to fulfill Java's original intended use. The day that Java is relegated to a few zealous geriatrics (like Lisp is today) is going to be a happy day.

First, get Red5. Get the .deb from Red5 here. Next run the deceptively simple installation command:

sudo dpkg -i red5_0.7.0_all.deb

On a stock Ubuntu system it will fail horribly. It needs sun-java5-jre.

sudo apt-get install sun-java5-jre

Amazingly, this doesn't work without half an hour of Googling why. It fails with an unsatisfied dependency "sun-java5-bin". Which if you try to install you get an unsatisfied dependency of "sun-java5-jre". Which if you try to install you get a helpful unsatisfied dependency of "sun-java5-bin".

The solution is to run:

sudo apt-get install

And accept their nefarious license agreement. But a quick check of the process list will show that there is no Red candy. There are no error messages to speak of, this is a wonderful example of Java in action. If you snoop around you find /etc/init.d/red5. Why not try and start it?

sudo /etc/init.d/red5 start

Well. It says it started. That's odd, there's nothing in the process list. It looks like it's calling a script /usr/lib/red5/red5.sh. Let's try that.

sudo /usr/lib/red5/red5.sh

Aha! A typical 50 line Java exception. I forget exactly what the exception is, don't really care. The solution is to run:

sudo update-alternatives --config java

Then select the sun-java5-jre option. This exception is ocurring because our wonderful Ubuntu overlords don't like the fact that Java is closed source. They'd rather that we use GCJ for politcal reasons. It is because of this they decided to waste my time. Thankfully, Sun finally pulled their head out of their ass and released their pile of crap as Open Source(tm), which should save us headaches when we have to use this crap in the future. Another run of /etc/init.d/red5 start will give us a working Red5. You should be able to navigate to it at:

http://localhost:5080/

Next we need to install Eclipse, at least if you want to do any development. For those of you who are unaware, java is such a poorly designed language that it requires a mammoth IDE in order to get any work done in it.

# Don't run this, read on for a fix.
sudo apt-get install eclipse

This doesn't work. Yes, it will install Eclipse. Unfortunately, the Ecplise it installs will not work. There is a user friendly Java exception in the upper right corner. The solution is to open "/etc/eclipse/java_home" and move (or add) the line "/usr/lib/jvm/java-1.5.0-sun" at the top of the file. This is because Eclipse is too dumb to find the right JVM on its own. Additionally, the Eclipse version which is in the Ubuntu repositories is too old, it will fail several hours after tweaking with it trying to make it work with Red5. So instead download the Eclipse IDE for Java EE Developers (version 3.3.2 as of this writing.) Untar the file and move it to /usr/local/eclipse.

tar xvfz eclipse-jee-europa-winter-linux-gtk.tar.gz
sudo mv eclipse /usr/local

Now start the Eclipse IDE like so:
/usr/local/eclipse/eclipse

This will fail trying to write a few files to various places which require root access. The program appears to be ignorant about file permissions. You can start it once with:
sudo /usr/local/eclipse/eclipse

Then close it and start it again and the problem seems to go away. You may need to add or edit /etc/eclipse/java_home or not. Now you need to install Springboard or whatever the fuck it's called. The instructions are here. An important thing to notice here is 'Don't try to install the "Spring IDE Dependencies (only for Eclipse 3.2.x)" from the "Dependency"'. Typical of Java developers, their program is not smart enough to figure out which version it is and handle this for you. You also need to install Subclipse for SVN management. And Poison Ivy if you want to build the Red5 system. I used Cal's excellent installation guide here. Otherwise, you appear to be able to build Red5 applcations without them.

If you need to connect to MySQL you can run:

sudo apt-get install libmysql-java

This installs JDBC and the MySQL Connector correctly.

No comments: