MetNet API - NetBeans Quickstart tutorial

Modern IDEs are wonderful creations. However you may need to spend some time getting to know yours. Once you have however, you can get so much more done quickly in a much shorter timespan.

Here we will get you quickly up to speed with NetBeans, Sun's free-of-charge IDE. Even as Sun is definitely a commercial company, we're happy to tell you that free in this context does not mean limited. Just like Eclipse, you can even use NetBeans for more than just Java alone. In case that's all you want to do however, you can download a packaged bundle which includes both NetBeans and the latest version of the Java SE JDK. Another nice feature is that it has built-in support for MySQL (which is also a Sun product now, I'm sure you're aware). So without further ado, let's get started.

Of course the first thing you should do is download the metnet3.jar file which contains the Java-implementation of the MetNet API. Store it on your local drive (c:\metnet\ would be a good location for it). That's actually all you need, since NetBeans comes equipped with the necessary JDBC-driver for MySQL out of the box.

Start a new project by going to File > New project. In the left Categories panel, pick Java. In the right Projects panel, Select Java Application. We're not planning to do anything fancy here. Click the Next button.

Name your project. We chose "MetNet4Java", but you can name it anything you want of course. Leave all the other settings to their default-values. You can change these later to suit your specific needs and preferences. Click the Finish button. After a few seconds, you should see a screen as the one below:

The first you need to do now is add a reference to the MetNet API .jar-file. In order to do this, right-click on the Libraries folder of your project, and click on Add JAR/Folder. Then browse to the location where you stored the file when you downloaded it. Click on the Open button to select the file and add it to your project. You can check the file is there by expanding the Libraries folder.

While NetBeans ships with the Java JDBC MySQL driver, you still need to reference it. To do this, right click on the Libraries folder again, but this time choose Add Library. From the Global Libraries folder, select the MySQL JDBC Driver. Click the Add Library button. You should see both libraries (MetNet and MySQL) references in the project explorer panel:

Now back to your code. Between the package declaration and the void main() declaration, request to import any of MetNet classes that you plan to use. As you start typing import edu.iastate.metnet., you'll notice that intellicode helps you prevent typos. This automatically rendered assistence is the first sign that you've done everything correctly up to this point. If you don't see the drop-down combobox appear, you shoud revisit the paragraphs above because you may have missed something.

Let's do a real test of the API by writing a simple example program. We'll print out a list of supported MetNet organisms. So start by importing the import edu.iastate.metnet.Organism class. Therefore, alter the content of your void main() to contain the following:

    public static void main(String[] args) {
        Organism[] orgs =;
        for (int i = 0; i < orgs.length; i++) {

When you run the program, you should see a list of organisms currently in the database. If so, congratulations! You may well be on your way to build the next systems biology killer app. Your screen should look something like this:

Back to main