5 things every CSC student should do before Graduation
July 31st, 2009
Graduation day has arrived. You’ve learned enough sorting algorithms to make you more than mildly annoying at boring parties, giggled every time you misheard your professor say “sets”, and have come to hate the traveling salesman. You are ready to step out into the real world and make your mark.
Right?
There’s only so much time over the course of four years in which students are awake, sober, and mentally alert enough to be taught. It’s impossible for us to cover everything before unleashing you out into the wild. So after a bit of thinking back to my own trial by fire in the real world, I came up with a list of things any self-respecting geek should do before graduation.
SSH (or telnet) into another machine and do something
I’m not trying to scare you, but chances are, you’re going to find yourself working on a machine without the comfort of a GUI available. As the mouse sits there uselessly taunting you, you’ll be left with a blinking cursor and no idea what to do next.
At some point before graduation, develop some command line proficiency. Learn the basic commands for navigating between directories (cd), listing files (dir on Windows, ls on Linux/Unix), and a few other commands to make you reasonably comfortable on the occasions where you need to connect to a remote machine. Everyone from a system admin managing multiple offices to a developer who needs to work on a QA or production box will at some point need to connect to a machine over the network and get something done..
Learn Vi or Emacs
The premise here is simple: learn a real text editor. No, Wordpad doesn’t count. Anyone who suggested Notepad, please sit down and keep reading.
There is a long standing religious feud between vi and emacs, much like Coke v. Pepsi, Yankees v. Mets, and “Tastes Great” v. “Less Filling” (I’m afraid that last one may have just showed my age). Most people fall in love with one and consequently adamantly hate everyone from the other camp. I personally tend towards emacs, but in a pinch I know how to navigate around vi to get the job done.
There are a bunch of reasons this is important. Both editors are powerful, providing users with a number of speed enhancing features. I know developers who use these in place of full blown IDEs. Both offer text-only versions, which will come in handy in the above scenario of working on a remote machine from a command line. Both (or at least vi) will be available on pretty much any Linux/Unix machine you find and can also be installed on Windows. Both also have very active communities, so finding tutorials on the internet should be simple.
Oh, and for the record, vi is pronounced as the two letters that make up it’s name (“vee-eye”). Don’t call it “six” thinking you’re being cute and reading it as a Roman numeral. Best case, you get laughed at. Worst case, someone throws something heavy at you.
Set up a LAMP server
A LAMP server refers to a machine running a suite of the following open source software:
- Linux – Operating system
- Apache – Web server
- MySQL – Database
- PHP – Programming language
The configuration has become so popular that the term “LAMP” has arisen to describe the four aspects (the first letter of each of them if It’s not clear).
Why? It’s a great introduction to a ton of different things you’ll likely need in the real world. If you’re reading this, I don’t need to explain to you why learning the fundamental blocks of building a web server are important. A LAMP server provides all of these pieces. It will also give you experience in dealing with configuring and connecting to databases, which will come in handy on, well, pretty much every project you’ll ever work on.
On top of that, there are some really cool open source apps written in PHP to install and dork around with. Wordpress (blogging software; used for this site), Gallery (photo sharing site), and phpbb (forums) are just a few of the open source applications you can download, install on your LAMP server, and tweak as much as you want. Bonus points if you check out the source code for these applications from their respective repositories.
This also makes for great resume padding, since it shows enthusiasm, curiosity, and technical ability.
Ok, ok, I’ll even bend a little bit. If this seems too daunting, take out the Linux part and do it on Windows. Just know that I’ll be disappointed in you.
Dual boot your system
Ok, I lied about bending. Given the size of hard drives these days, there’s no reason you can’t spare a few gigs to install a second operating system. The Linux installer is extremely friendly towards these types of setups. It will even go so far as to set up a menu when you boot to let you pick which operating system you want to boot into.
Dual booting allows you to hold on to a Windows installation while still giving the option to play around and learn Linux. And using Linux will make you a bad ass.
Install new hardware into a desktop computer
When I was 10, my dad showed me how to install a memory stick into a computer. He then informed me that the 4 seconds it took me to do it would have cost upwards of $30-$50 per stick at any local computer store. That’s not a bad rate for something that takes the same dexterity as putting bread into a toaster.
I’d like to have made this point “build a computer”, but I realize I’m talking to college students who can barely afford Ramen, much less the parts necessary for a desktop. But I do realize that at some point, you’re going to have an upgrade that needs installing. Do it yourself. It’s not as scary as it sounds and you’ll save a ton of money.
And while you’re in there, air dust it. If you’ve never done it I guarantee you’ll find a small furry creature has set up camp in one of your fans.
Getting Started with NetBeans – Editing
July 29th, 2009
So far we’ve created a NetBeans project and written and compiled our first class. What do we have to show for it? A few directories and a Java file.
Big deal.
Thankfully, that’s just the beginning. Now that we’re at a point where we can start to code, the fun stuff begins. Ultimately I want to cover writting/running test cases, using a debugger, refactoring, and building/running executable JARs. But first, let’s take a look at some of the perks the NetBeans editor gives us.
Autocomplete
Autocomplete is one of my most used features in an IDE. The idea is that since Java is strongly typed* you can have NetBeans tell you possible methods that can be executed on an object given its type. To trigger the autocomplete, type the period after the object reference and press ctrl+space. A drop-down will appear showing the possible methods that can be invoked on that object.
* If you don’t know what that means just yet, your professor had better cover it.

In the above example, the drop-down shows all methods that can be executed on the out object. Most students will be familiar with the println method, however the autocomplete shows there are a number of other methods exposed by the out object that can be called. Keep in mind that in this case I didn’t scroll down far enough to show the println(String s) method which most students have used in the past. It’s still there, it’s just not shown in the screenshot.
Below the drop-down is the javadoc for the currently selected method (println in this case). This displays whatever documentation the author felt was necessary to properly use the method, including a description of what is returned and explanations of any parameters the method takes.
ctrl+space. The drop-down will only display entries that could finish the text you’ve already typed. So in our System.out example, if we type “prin” before pressing ctrl+space, NetBeans will only show methods that begin with “prin”.
Syntax Highlighting
Take another look at the above screenshot. Notice how the System.out snippet is underlined with a wavy red line (is there an actual name for that style of line?). Also notice the line number has been replaced with a warning indicator. Both warnings indicate that the line is invalid and won’t compile. In this case, what we’ve typed (System.out) isn’t a valid line of code. Once this is completed, for instance with a call to println and a semicolon, the warning indicators will go away.
This is a great teaching assistant for new programmers. Compiler errors can be… well, they aren’t always all that clear. Hovering over the code marked as invalid will display a tool tip describing the error. In this case, hovering over the snippet displays “not a statement”. This can be a tremendous help when still learning the syntax of the language. It’s not just for beginners either. Many veteran programmers appreciate the extra pair of virtual eyes that the IDE provides through this mechanism.
Code Templates
I referred to this in an earlier blog entry, mistakenly using the IntelliJ term “Live Templates”. The concept is the same in both IDEs. The user types a short abbreviation and uses the tab key to have the IDE automatically expand it into full code.
To see the templates provided by default in NetBeans, navigate to the Tools -> Options menu item, select Editor from the top set of icons, and Code Templates from the tabs below. There are a number of them defined, so rather than sit there attempting to memorize them all, here’s a quick list of ones I regularly use and the text they expand into:
- psvm – public static void main
- psfs – private static final String (useful for defining local constants)
- sout – System.out.println()
You’d be surprised how useful it becomes, especially if you’re a slow typer. Between these and the autocomplete, we’ve already addressed two powerful features to limit how much code you actually have to manually type. I’d guess I only ever fully type out about 10% of the code I write.
In addition to the default templates, users can create their own. This can come in especially handy when you’re working with a particularly verbose API. I won’t get into the full specifics on the syntax of defining a template now, but it’s worth taking a quick look at the “sop” template:
System.out.println("${cursor}");
Notice the odd ${cursor} piece in the middle. That’s an example of the variable capabilities in the template definition. The ${cursor} snippet will leave the cursor in that position after the text is expanded. That makes sense, since you’ll likely want to type something into the parameter (notice the quotation marks are included in the template definition).
There are more possibilities for these syntax variables. The help button on that screen provides a link with more description. I’m not necessarily suggesting that a new Java developer dive right into defining complex code templates, but at least knowing it is there for future reference is valuable.
Comment a Line of Code
Pressing ctrl+/ at any point in a line of code will comment out the entire line of code. Pressing it again will uncomment the line. It may sound dumb, but when you’re incrementally debugging a block of code, you may find yourself using this quite frequently.
I’ll stop there for now. Too much at once will just start to melt brains.
I don’t have a specific “Editing Part 2″ in mind just yet, but I’m sure there are editing features I cannot live without that I have yet to touch on. We’ll see where my blogging motivation takes me next in this series.
Student Blogging
July 28th, 2009
There’s been a discussion going around the blogs on the teachingopensource.org planet blogs about teacher/student blogging that’s really gotten some interesting ideas going. It started out with a great post by Matt Jadud outlining some basic tenants of a blog in a guide for students. It also got picked up by David Humphrey which highlighted that it’s important for teachers to serve as a model for this sort of learning reflection as well.
My blog (as in, the one I’m writing this on) started out as an experiment to give students some outside information I thought they could use but couldn’t fit into class time. It’s since evolved (and continues to do so) into the sort of technical blog that I’ve found helpful in the past when looking for an answer to a specific question.
That evolution has proven to be important. Using a blog as the medium allows me to introduce a lot more of my personality into the entries than if I were to write a formal academic textbook. I think that’s a really important concept that I’ve seen unfortunately get lost on a number of professors. I’ve always found it easier to keep interested in a more conversational tone than when reading a preachy lecture.
My blog also gives a good insight into my tech-related projects and interests. I know many professors are looking for students to get involved in their research and projects. Often, the students either don’t know about the projects or are first presented with an ominous (read: cold, formal, dull) white paper describing the research. A blog is a natural marketing tool (not my word, I think Matt used it, but it’s a great term) for driving interest in these projects.
Meanwhile, a student authored blog is, among other things, a resume-padder. When I interview candidates, one of the most important factors I look for is enthusiasm. I want people who enjoy doing this stuff. A blog, even if it’s not 100% technically focused, shows the level of interest I’m looking for. Bonus points if you installed and administer the blog software yourself. Extreme bonus points if you contributed back to the blog software you used.
It’s also practice. I had one particular CSC professor stress the ability to write. I didn’t fully understand it at the time; I was going to be a coder and wouldn’t need to write. I’ve since told her, on a number of occasions, how much I came to appreciate the experience. The English/History/Philosophy papers students are writing for other classes are a very different voice than trying to explain to someone else why a project is a good idea or how you got around a particular bottleneck. Getting a feel for how to do that early on will be a tremendous advantage when students find themselves on team projects.
And like Matt said, it can even help propagate the awesomeness of keyboard cat.
Getting Started with NetBeans – Your First Class
July 26th, 2009
Once the NetBeans project is created (blog entry here if you missed it), we can get coding. Rather than abstractly going over the NetBeans UI, I’m just going to dive into getting the Hello World application running.
First off, go ahead and close the Start Page tab. It’s just in the way right now.
Creating a Class
You can ask NetBeans to create a class either through the File -> New File option or by right clicking on the Source Packages listing in the Projects tab to the left (it should be under a tree root called “HelloWorld”, which is the Project Name specified back at project creation time) and selecting “Java Class”. I prefer the latter option.
This brings up the new class creation screen which looks more daunting than it actually is. There are two important fields here. The Class Name field is exactly what it sounds like: the name of the class being created (don’t forget proper capitalization). The Package field indicates the package in which the class will be put, creating the package if it doesn’t exist (if you don’t know what a package is, leave this blank for now, soon enough this will be covered in class).
NetBeans will generate and display the exact path to the file being created. Notice that the file is put in the src directory (unless you accidentally right clicked on Test Packages initially). Also notice that if a package is specified, NetBeans will create the appropriate directory structure below the src directory.

In the above screenshot, a new class named MyHelloWorldApp will be created in the default package. Once the Finish button is clicked, the new class will be opened in an editor tab. NetBeans will take care of some of the basic structure of the class, including class declaration and some basic javadoc comments.
Implementation
This section could be huge if I were to go into the various code writing assistance tools NetBeans offers. I’ll cover those more in future entries. For now, we’ll stick to the basics.
Navigate the left pane under Source Packages to find your class (trust me, this will look more interesting once packages are involved). If the class isn’t open, double-click the file to open it in an editor tab. I’ve provided a simple main method below:
public static void main(String[] args) { System.out.println("Hello World"); }
Compiling
There are a number of ways to compile depending on how much of the project you want to build. For now, I’ll stick with the left-pane-centric approach and suggest to right click the tree root (HelloWorld) and select Build.
So what just happened? Like last time, let’s look at a file browser to see what NetBeans actually did.

In addition to the three directories created when the project was first created, there are two more now.
- build – A build directory is used as a temporary directory into which project pieces are, well, built. Since we’re just dealing with a simple application here, the only task in building is to compile the classes, placing the resulting compiled classes in the classes directory. I say “temporary” in the sense that you should be able to delete it and recreate its contents by building the project.
- dist – The dist directory represents a fully built application ready to be distributed. For now, this will likely just be a JAR file containing all of the classes in the project (I won’t get into the details of what a JAR is yet). This is also where NetBeans will place the generated javadoc HTML files if they are created (the Run -> Generate Javadoc command if you’re curious).
One thing I really like about NetBeans is that the project structure is consistent with many Java projects. Once you get accustomed to the ideas of what belongs in a src or build directory, it becomes pretty simple to navigate virtually any other Java project (for instance, the many open source projects available).
Also notice the source file for the class, MyHelloWorldApp.java, has been created under the src directory. Again, if this class were in a package, the package directory structure would be present under the src directory.
Running
Since the MyHelloWorldApp class contains a main method, it can be run through the java command or, more to the point, through NetBeans. Again, there are a number of ways to do this and again, I’ll stick with the approach that focuses around the Projects tab in the left-hand navigation. Right clicking on any file that contains a main method will have an option in the menu for Run File. Selecting that option will run the main method of that class.
The section beneath the editor tabs contains any output from the execution. In this case, it’s simply the output of the main method’s println statement.
run: Hello World BUILD SUCCESSFUL (total time: 0 seconds)
For now, don’t worry about what the “BUILD SUCCESSFUL” message means. While this showcases one of what I believe to be cooler aspects of NetBeans, it’s too much to explain right now. Suffice it to say, the word “successful” is good while “failed” isn’t.
Happy Coding
At this point, we’ve covered the minimum necessary to start coding in NetBeans. There are still a ton of useful features that I’ll cover in future posts, but this should be enough to get to a point where you can start to experiment and play around.
Getting Started with NetBeans – Creating a Project
July 26th, 2009
At the end of last semester, I got together with a group of other CSC professors at Villanova to discuss the Algorithms & Data Structures I, II, and III curriculum. One of the topics of this meeting was how to introduce the students to using an IDE (wikipedia link). After a bit of research, the choice was made to go with the open source NetBeans IDE.
While I plan on covering aspects of NetBeans in class, I figured it’d be useful to have a written explanation for my students to refer back to. The NetBeans provided quick start guide is good, but it’s largely geared towards existing developers comfortable with a Java project structure. So over the course of a few blog entries, there are a few topics I want to highlight that are relevant to the projects in my class.
Installation
Installation, however, is not one of the topics I want to cover. To be blunt, I run Linux (regrettably most of my students don’t) and I don’t have a Windows box around to figure out the instructions for that platform. Instead, I’ll simply link to their download page and their install instructions. I suggest that my students download the “Java SE” download bundle from their download list (the “Java” bundle contains a number of extra features that are not used in class, so not including them will limit the amount of noise and distractions in the UI).
Creating a Project
NetBeans, or more generally most IDEs, aren’t used in the same way as a simple text editor. Instead of just opening one file to edit at a time, you first set up some sort of context around the source code. This is typically called a “project”, but don’t be surprised to see words like “module” or “workspace” used in a similar fashion.
Organizing code into projects has a number of benefits. A project keeps related classes linked. For instance, an online store would need classes such as a ShoppingCart, User, PurchaseItem, and so on. Keeping all of these classes in the same project will allow them to “see” each other and be used together for the application. If this seems confusing at first, don’t worry; many students are not introduced to multi-class programs until the basics have been covered. To my students specifically, I can vouch for the fact that this should be clear as our semester progresses.
Creating a new project in NetBeans starts at the File -> New Project menu. This kicks off the project creation wizard.
Step 1

The first step is to select a template for the type of project you’re creating. While there are a lot of options to choose from, many are just subtle variations on others. The default (Java -> Java Application) is a good starting point to get an empty project. Make sure this is selected and press Next.
Step 2

The next step is to specify where the project files should be created and stored. You’ll be asked for the following things:
- Project Name – This is usually just a user-friendly name you give to your project. NetBeans, however, also uses this as the name of the project directory (more on that later). For now I’ll just use the typical programming standby of “HelloWorld”.
- Project Location – This is a bit misleading. This is the root of where your specific project directory will go (again, more on this later). My suggestion for my students is to create a new directory (i.e. folder) to specify here that all class project will be stored in. For example,
C:\Documents and Settings\jdobies\csc1052. Don’t be confused by my screenshot; Linux directories look a little different than on Windows. - Project Folder – This is automatically determined by NetBeans (and annoyingly can’t be changed) by using the Project Name as the name of the directory inside of the Project Location. So given the above two examples, the project folder will be created as
C:\Documents and Settings\jdobies\csc1052\HelloWorld.
A small clarification of my suggestion from above: Specify the same Project Location (i.e. the csc1052 directory) for all projects for the semester, using a different Project Name each time to reflect each project. This way, all project code will be located in the same place, organized in folders based on each individual project.
I also suggest unchecking the “Create Main Class” option. It’s simply a shortcut to making a class for you, but that’s easy enough to do later. Personally, I’d rather start with an empty project and go from there.
Once all of these values are specified, press Finish to create the project.
What Just Happened?
NetBeans did a lot of stuff behind the scenes. I think it’s important to take a quick look to see what that process just gave us. Below is a screenshot of the contents of the directory I used in the Project Location field during the project creation wizard.

Ignoring my other projects, notice the highlighted HelloWorld directory which was created by NetBeans (again, the directory name was taken from the Project Name in the wizard). NetBeans creates three additional directories inside of the project directory.
- nbproject – Contains the files NetBeans needs to store information about the project. This can be safely ignored; you won’t need to directly interact with these files. However, keep in mind that directory and its contents are only needed by NetBeans; don’t get confused and think these are part of your project (so they don’t need to be submitted to your professor).
- src – The directory name “src” is the typical abbreviation for “source code” and is where the actual code for your project will go. NetBeans will automatically put most classes in here for you, but it’s important to know where they ultimately end up (I’ll come back to this later when we create a class).
- test – This is another typical convention seen in many projects. Often, code that is used to automatically test your application is kept separate from the product code itself (don’t mistake that to mean it is any less important). Testing is a huge topic so I won’t go into any more detail here.
The other two files shouldn’t need to be edited either. The short answer is that NetBeans will use them to compile and run your project, so don’t touch them.
Now What?
Once the project is created, you’re dropped to the main NetBeans screen. The next steps will be to create a class, compile, and run the main method from inside of NetBeans. I’ll cover all of that in the next post.
Three Years
July 20th, 2009
Last Friday marked three years for me here at Red Hat. The last year has been a fun transition from the RHQ team to the Spacewalk team, and it’s already looking like the coming year is going to be, to say the least, interesting.
I’ll spare everyone the sight of me in my red fedora (maybe next year) and will stick with Red Hat’s solid Truth Happens video instead:
Amazon MP3 Downloader on Fedora 11
July 3rd, 2009
I’ll cut to the chase: it doesn’t work. But have no fear, there’s an OSS solution.
I recently got into using Amazon for buying MP3s. It’s DRM-free and has a great integration with pandora.com, which lets me hear a new song and click directly in pandora’s interface to buy it. It’s technology at its finest, if not its most dangerous (to my credit card).
Amazon is annoying in the sense that you can download single MP3s as an MP3 file, but to buy a full album you have to use their proprietary downloader. This was bearable until a recent change where all MP3s now have to be downloaded using their downloader.
The problem? The most recent build of their client is for Fedora 9 (or Ubuntu 8.10 if you go that route). So their software is, um, I’ll just say “not up to date”. I was able to hack around to get it to run under Fedora 10, but it’s flat out busted in Fedora 11.
As I said at the outset, there is hope. Clamz is a command line app to download MP3s using Amazon’s .amz formatted files. It’s exactly what you think it is. You download the .amz file from Amazon (at the point in Amazon’s workflow where you should be just downloading the MP3 itself) and run the clamz executable passing in the .amz file. Poof, it just works.
I’m disappointed it has to come to this. I know Fedora 11 is still new, but that doesn’t change the fact that there was never a Fedora 10 build (and still is no Ubuntu 9.4 build) of the Amazon downloader. Serious good karma to the Clamz project for stepping up and filling this need (at least until I find a new outlet for buying MP3s; if Amazon doesn’t want to let me buy from them then I’m not gonna go nuts trying to).

