Skip to main content

HOWTO: Setting Up a New Ubuntu GNU/Linux Box for Java/CFML Development

Since I wind up doing this every six months with each new release of Ubuntu, I thought this time around I'd document how I set up an Ubuntu GNU/Linux box for Java and CFML development. This is partly so I don't scratch my head thinking "was there anything else?" next time, but mostly for people who want to dive into GNU/Linux from another platform and need a quick step-by-step guide to help them get productive quickly.

Note that if you're setting up an Ubuntu server, the server-related stuff that follows (Apache, Tomcat, and MySQL) will be pretty much the same on a server as it is on a dev machine with a couple of differences. First, you'll want to have Tomcat autostart at boot on a server (which I don't do on my dev machine). Second, and this is a matter of personal preference, I tend to put Tomcat in my home directory on my dev box, but in /opt on the server.

So open up a terminal and let's the the easy apt-get stuff out of the way first.

sudo apt-get install apache2

sudo apt-get install mysql-server mysql-client


sudo apt-get install vim emacs

You can also install Java and Tomcat via apt-get, but I prefer to download these items directly from their respective sources. We'll start with Java.

  1. Open a browser and go to (sorry Oracle, I'm not using your URL until you turn this one off!)
  2. Mouse over "Downloads" and click on "Java for Developers"
  3. Scroll down a bit on the next page and click on the "Download JDK" button (you'll want the full JDK, not just the JRE)
  4. On the next page, click on the Platform button and choose either "Linux" (32-bit) or "Linux x64" (64-bit) as appropriate for your machine. Then scroll down and hit the "Continue" button.
  5. Under "Available Files" on the next page, click on the .bin file, not the .rpm.bin file.
  6. After the download completes (and I'm assuming you downloaded to your Downloads directory), open a terminal and do the following, hitting enter after every line (note the file name may be different based on the version you download):
    cd ~/Downloads
    chmod +x jdk-6u22-linux-i586.bin
  7. You'll see all the files extract, and you'll wind up with a jdk1.6.0_22 directory (or perhaps something different based on the version you downloaded). Personally I like to have Java in my /opt directory, so if you want to follow suit, type the following in your terminal (again hitting enter after each line):
    sudo mkdir /opt/java
    sudo mv jdk1.6.0_22 /opt/java


With Java in place, I like to set a couple of variables in .bashrc to make Java and Java applications a bit easier to work with. Navigate to your home directory (cd ~/) and open up .bashrc in vi or your favorite editor. Note that if you're new to GNU/Linux, the . before the file means it's hidden, so you won't see it in a plain old ls, but of course ls -a will show it.

With .bashrc open, scroll down to below the HISTSIZE and HISTFILESIZE lines (at least that's where I put this stuff), and you're going to add the following lines:

export PATH
export JAVA_HOME

Save the file, and then you'll have to log out of your terminal and log back in for these settings to take effect. Type exit and then hit enter to close your terminal, and then re-open the terminal. To make sure your settings took, type the following in your terminal, hitting enter after each line:

echo $PATH

You should see the Java directory included in your path, as well as see it for the value of JAVA_HOME.

Note that by editing .bashrc the changes only affect your user. If you want these settings available to all users, you'll be editing /etc/profile instead.

With Java in place, let's grab Tomcat. You can of course substitute a different JEE server or servlet container if you're so inclined, but if you do you're on your own for the setup. ;-)
  1. Go to in your browser.
  2. On the left-hand side under "Download" click on the latest version, which is currently Tomcat 7. (Note that Tomcat 7 is still technically in beta if you care about such things.)
  3. On the download page, scroll down a bit and under "Core" click on the .tar.gz link.
  4. After the file downloads (again assuming you have downloads go to your Downloads directory), in your terminal do the following (hit enter after each line):
    cd ~/Downloads
    tar -xvf apache-tomcat-7.0.2.tar.gz
  5. You'll see the files extract, and at the end of that process you'll have an apache-tomcat-7.0.2 directory in your Downloads directory. I prefer to have that in my home directory on my dev boxes, so type this in your terminal and hit enter (assuming you're still in your Downloads directory):
    mv apache-tomcat-7.0.2 ../
  6. Next to make Tomcat a bit easer to access, we'll add a symlink called tomcat that points to the real Tomcat directory. More terminal stuff:
    cd ../
    ln -s apache-tomcat-7.0.2 tomcat
With all that in place you can now access the Tomcat directory structure via ~/tomcat which I find pretty handy.

Next we need to configure Tomcat a bit, so in your favorite text editor, create a file in Tomcat's bin directory. If you want to do this in your terminal with vi, type the following:

cd ~/tomcat/bin

What we'll be adding to this file is some settings that Tomcat will use when it starts up. Depending on your machine and/or preferences you may want to adjust the memory settings, but if you aren't sure what this stuff does, these are decent generic settings and you can always change them later.
Add these two lines to and then save the file:

export JAVA_HOME=/opt/java/jdk1.6.0_22
export CATALINA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=384m"

Again if you know what you're doing here, feel free to change your memory settings accordingly.
You should now be able to fire up Tomcat without any errors, so navigate to ~/tomcat/bin in your terminal and type ./

You'll see a few lines spit out to the terminal, and if you don't see errors, open up a browser and go to http://localhost:8080 If you see the Tomcat welcome screen you're good to go.

Note that I won't be covering additional Tomcat configuration here, particularly hooking it into Apache, because there are a ton of other howtos and blog posts about that very topic. If you have specific questions in this area I'm happy to help, so comment below and I'll either comment or write another blog post as necessary.

There's one additional bit of configuration I tend to do because particularly on a dev box, you'll run into a problem with this sooner or later if you abuse your machine like I do.

In a terminal (you and your terminal are friends by now, right?), or using your favorite text editor, you're going to edit /etc/security/limits.conf to increase the maximum number of files your user can have open. Open that file and add the following lines to the bottom of the file:

yourusername soft nofile 10000
yourusername hard nofile 10000

Unless you already have a favorite Java IDE, much as it's not in fashion to say so I'm a big fan of Eclipse. I personally have been using SpringSource Tool Suite (STS) for quite a while now, and it's a great Eclipse-based IDE for Java, Groovy, Grails, and of course CFML development once you throw in CFEclipse.

After downloading the Eclipse or STS of your choice, extract the files and then move them to your home directory (at least that's where I put them). This should be old hat by now--in your terminal do:

cd ~/Downloads
tar -xvf NAME_OF_FILE_HERE.tar.gz

STS has a bit of a different directory structure since it comes with tcServer and Roo, so you'll actually go into the directory and be moving the STS directory into your home directory. Since it has a long name like springsource-tool-suite-sts-2.3.2-RELEASE or something like that, I tend to move and rename to something shorter, e.g.:


Once things are moved, you can go into the directory that you moved to your home directory (which will be either sts or eclipse most likely), and then type either ./STS or ./eclipse to launch the program.

Although you can certainly start STS or Eclipse from the terminal if you like, most people tend to like to have a pretty button to click on to launch the program. The bad news is you have to add this yourself. The good news is it's very easy.
  1. Right click on the Ubuntu logo in the top left of the screen, and click on "Edit Menus."
  2. Click on "Programming," and then click on "New Item" on the right-hand side of the window.
  3. Leave the type drop-down set to "Application"
  4. For "Name" type whatever you want the name to be (e.g. Eclipse, SpringSource Tool Suite, whatever)
  5. For "Command" you need to tell the launcher not only where the executable is, but also where to find Java. So assuming your executable is ~/eclipse/eclipse you'd enter the following in the Command box:
    /home/yourusername/eclipse/eclipse -vm /opt/java/jdk1.6.0_22/bin
  6. You can leave the "Comment" box blank, but if you enter something here it's what will show up when you mouse over the icon for the application.
  7. Click on the "spring"-looking icon in the left-hand side of the Create Launcher box and you can choose an icon. Note that they're kind of in a weird format. STS comes with its own icon so you can navigate to the STS directory and select the icon.xpm file. If you're using Eclipse you can search for 'eclipse icon launcher ubuntu' on the interwebs and find stuff you can use.
  8. Click OK and your launcher will be added to the Programming menu when you click on Applications in the top left of the screen.

If you're a CFML developer you likely already know how to install CFEclipse and since Eclipse is Java based it's the same on every platform. If you're not familiar with installing CFEclipse, head on over to the web site and you'll find great instructions.

That's pretty much it! You're now a hard-core Java/CFML developer on GNU/Linux, other than all that pesky Tomcat/Apache configuration of course. As I said earlier if you need help with that, comment below and I'll do my best.



Neurotic said…
Any reason who you don't add the Ubuntu partner repositories, and install Java that way? Or do you like to have tight control over which version of the JDK you have on the machine?
Matthew Woodward said…
Right Mark--I just like to know exactly which Java I'm getting and have the flexibility to manage Java myself. That's the only real reason.
Akbarsait said…
The steps are really helpful and handy. Thanks for posting.

Popular posts from this blog

Installing and Configuring NextPVR as a Replacement for Windows Media Center

If you follow me on Google+ you'll know I had a recent rant about Windows Media Center, which after running fine for about a year suddenly decided as of January 29 it was done downloading the program guide and by extension was therefore done recording any TV shows.

I'll spare you more ranting and simply say that none of the suggestions I got (which I appreciate!) worked, and rather than spending more time figuring out why, I decided to try something different.

NextPVR is an awesome free (as in beer, not as in freedom unfortunately ...) PVR application for Windows that with a little bit of tweaking handily replaced Windows Media Center. It can even download guide data, which is apparently something WMC no longer feels like doing.

Background I wound up going down this road in a rather circuitous way. My initial goal for the weekend project was to get Raspbmc running on one of my Raspberry Pis. The latest version of XBMC has PVR functionality so I was anxious to try that out as a …

Setting Up Django On a Raspberry Pi

This past weekend I finally got a chance to set up one of my two Raspberry Pis to use as a Django server so I thought I'd share the steps I went through both to save someone else attempting to do this some time as well as get any feedback in case there are different/better ways to do any of this.

I'm running this from my house (URL forthcoming once I get the real Django app finalized and put on the Raspberry Pi) using I don't cover that aspect of things in this post but I'm happy to write that up as well if people are interested.

General Comments and Assumptions

Using latest Raspbian “wheezy” distro as of 1/19/2013 (’lll be using Nginx ( as the web server/proxy and Gunicorn ( as the WSGI serverI used heavily as I was creating this, so many thanks to the author of that tutorial. If you’re looking for more details on …

The Definitive Guide to CouchDB Authentication and Security

With a bold title like that I suppose I should clarify a bit. I finally got frustrated enough with all the disparate and seemingly incomplete information on this topic to want to gather everything I know about this topic into a single place, both so I have it for my own reference but also in the hopes that it will help others.Since CouchDB is just an HTTP resource and can be secured at that level along the same lines as you'd secure any HTTP resource, I should also point out that I will not be covering things like putting a proxy in front of CouchDB, using SSL with CouchDB, or anything along those lines. This post is strictly limited to how authentication and security work within CouchDB itself.CouchDB security is powerful and granular but frankly it's also a bit quirky and counterintuitive. What I'm outlining here is my understanding of all of this after taking several runs at it, reading everything I could find on the Internet (yes, the whole Internet!), and a great deal…