Monday, March 15, 2010

Running BlazeDS on 32 bit Ubuntu Linux 9.04

This is a topic that will appeal to a very narrow minority (smart, not-frightened to try new stuff, developers). I have always loved Linux and lately found myself totally thrilled with Ubuntu. I've now run 9.04 on a Mac Pro in VMware and have a dual boot 64-bit install running Ubuntu 9.10. What can I tell you? If Adobe had an approved Exchange client for Ubuntu, I'd say bye-bye to OS X. Check out the screenshot:

There really isn't that much to get BlazeDS up and running on either of these systems, largely thanks to the ease of use built into Ubuntu. Here are the instructions to get it up and running.

1. Grab the Vancouver build of BlazeDS from here.

2. Unzip it to your desktop. Ubuntu 9.04 makes this simple as all you have to do is double click on the *.zip package, the same as OS X or Windows.

3. Check to see if you have a JDK configured and installed. To do this, grab a terminal and type in "javac" and see what comes back. If you have not installed a JDK before, you will get a message similar to this one:

4. This means you have to use a great feature of Ubuntu. The apt-get command is a powerful command-line tool used to work with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages and more. It can even update the O/S. apt-get has numerous advantages over other package management tools available in Ubuntu for server administrators. Some of these advantages include ease of use over simple terminal connections (SSH) and the ability to be used in system administration scripts, which can, in turn, be automated by the cron scheduling utility.

5. Run the command "sudo apt-get install sun-java6-jdk". This will install the Sun Java JDK. I chose this one over the others as I consider it the reference implementation for a JDK. Once you hit enter, you will be asked for your admin password and then the magic begins. I swear this was the easiest Java install I have ever done in my life. Thank you whoever created this tool at Ubuntu!!!

6. At some point during the install, you will be hit with the Sun license agreement. There will be a little (yes) prompt at the bottom of the grey area and none of the regular keys or mouse inputs seem to get you to be able to interact with it. You have to use the TAB key for this. Tab over until the (yes) is highlighted (shown below) and hit enter. Same for the next screen.

7. When this completes, you should be able to type "javac" into the command line and see the proper output (basically a prompt asking you for options).

8. Navigate to the folder where you saved the BlazeDS build from step 1. Using the terminal, chmod it to make it executable ( chmod -R 755 BlazeDS/ ). Chmod makes the file persist in a mode of "executable" if given the 755 argument. You may have to change to su to do this. This can be accomplished by typing in "sudo" in front of the command.

9. You're almost ready to start it up. The last step is to set $JAVA_HOME. To do this, you have to modify a small properties file that controls the environmental variables when in the terminal. This file is usually in your home directory. To switch back to this directory just type in "cd ~" and then type in "ls -la .bash*". This should provide a list of files that are hidden (from just running "ls") and you will see one such as .bashrc or .bash_profile. This is assuming you are running the BASH shell.

10. You will have to edit the .bashrc or similar file to add a line that sets the $JAVA_HOME environmental variable. First you have to know what this value should be. Within the terminal, type "whereis java". This should provide a list of locations where Java is installed.

My system returned the following:

administrator@ubuntu-904:~/Desktop$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

11. Unfortunately, the process is not quite straightforward. Grab a File Browser and navigate to the first path you see (in this case /usr/bin/) and inspect "java". On my system and many others, this will turn out to be a symbolic link to another location. To find out where, right click on it and select "Properties". Mine showed the location as /etc/alternatives/java.

12. Navigating to /etc/alternatives/java also revealed that this too was a symbolic link. The real target was /usr/lib/jvm/java-6-sun/jre/bin/java. This means that the real value for $JAVA_HOME will be /usr/lib/jvm/java-6-sun/.

13. To set this, use a line editor of your choice. I am going to use pico as pico is one I am familiar with. To do this, type the following in your terminal:

- "cd ~"
- "pico .bashrc"

14. Pico should bring up a configuration file. If it is not already filled in with lots of values, check the name of the config file and try again. In this file, you can add comments so I usually append my custom entries to the bottom of the file. In this case, at the very bottom, I enter the following lines of code:

# JAVA_HOME added by Duane Nickull
export JAVA_HOME=/usr/lib/jvm/java-6-sun

15. To save your .bashrc profile use "Control X" and answer "Y". Quit the current instance of terminal and open a new one. Test that your JAVA_HOME environmental variable is okay by typing in "echo $JAVA_HOME". You should see output like below:

16. With your terminal, navigate to the BlazeDS root folder, then change directory to the "sampledb" folder. Type in the following: "sh". The sample database should start up.

17. Start another instance of terminal and navigate to the BlazeDS root folder, then navigate to subfolders "tomcat" and "bin". Type in the following: "sh run".

18. Fire up a web browser and navigate to http://localhost:8400 (the default port the BlazeDS will be running on). Voila! You are done.

Coming up next will be some tutorials on Flex and AIR development on Linux if anyone is interested.


  1. A good way to see where java is located is to list the files in the package:

    dpkg -L sun-java6-jdk

  2. THanks Erik! I am just getting back into Linux after being disillusioned with both PC and OSX O/S's and really loving Ubuntu. Now if I could only encourage my company to make CS for Linux.... D'oh!!!

  3. CS6 for Linux would really be something. You absolutely have my vote!

  4. I have successfully installed blazeds on ubuntu server thanks to your article. Now when I try to create a flex project on windows and connect to ubuntu server, I mapped the root folder to my windows file system, when I click the validate configuration on flash builder 4, it shows the root folder is invalid.
    Solutions? Many Thanks!

  5. @mimi - what value are you entering for the connections? It must be visible to your dev machine (anything lower than the root access you have will not work).

  6. Could you please tell me where to find comparison between BlazeDS 3.x and 4.x. I am unable to find what's new in 4.x anywhere. Maybe I have been looking at all the wrong places.

  7. For sure! The release notes are here.

    They outline all the fixed bugs and features.

  8. Great thanks for this tutorial !!!
    I'd like to use it on production server.
    However, could you please specify me where to unzip BlazeDS build on a ubuntu tree structure ?
    Thank you in advance for your help.


  9. @onrollover

    Once you have ensured the JAVA_HOME is set, you can literally place it anywhere you want. I put mine on the Desktop for development since I do a lot of demos for Adobe and like to not have to "cd" too much from my home directory to start it up.


  10. By following step by step your tutorial and your comment advice, BlazeDS samples work very well on my online VPS !!!
    Thanks for that !
    I plan to use it on an e-learning plateform, but I usually code in PHP with remoting AMF (not in Java).
    So, I wonder if it's possible 2 applications to communicate together on the same website, one based on BlazeDS messaging and compiled with J2EE server in Flash Builder and the other based on AMF remoting services compiled with PHP server in FB4 too, ? Possible conflicts ?
    Thanks for your tips.

  11. I keep getting the following error:

    Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    At least one of these environment variable is needed to run this program

    I know the Sun JDK is installed. My bash.bashrc file has the following at the top:

    export JAVA_HOME=/usr/lib/jvm/java-6-sun

    What could be wrong?

  12. Set JAVA_HOME / PATH for single user

    Login to your account and open .bash_profile file
    $ vi ~/.bash_profile

    Set JAVA_HOME as follows using syntax export JAVA_HOME=. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:
    export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

    Set PATH as follows:
    export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

    Save and close the file. Just logout and login back to see new changes:
    $ echo $JAVA_HOME
    $ echo $PATH

    Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
    $ which java

    Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.


Do not spam this blog! Google and Yahoo DO NOT follow comment links for SEO. If you post an unrelated link advertising a company or service, you will be reported immediately for spam and your link deleted within 30 minutes. If you want to sponsor a post, please let us know by reaching out to duane dot nickull at gmail dot com.