Using Eclipse to Write HelloWorld in Java for the Overo

From Gumstix User Wiki
Revision as of 14:21, 27 July 2010 by JustinC474 (Talk | contribs)

Jump to: navigation, search

This page will teach you how to create a simple, graphical, java HelloWorld application in Eclipse, export it to you Overo COM, and subsequently run it. This guide assumes that you have already run through Eclipse on Gumstix for new users and have Eclipse installed, and your Gumstix properly connected.

Writing HelloWorld.java in Eclipse

First, you need to write your Java program in Eclipse. This section will show you how to write a small graphical HelloWorld program in Eclipse.

  • Navigate to File-> New-> Java Project
  • Name the project HelloWorld
  • Select "Finish"

Once the project is created,

  • Select File->New->Class
  • Name your class HelloWorld
  • click "Finish"

Add the following code to your class:

   import javax.swing.JFrame;
   import javax.swing.JLabel;
   public class Hello {
   	public static void main(String [] args) {
   		JFrame frame = new JFrame("hello");
   		final JLabel label = new JLabel("hello from Gumstix");
   		frame.getContentPane().add(label);
   		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   		frame.pack();
   		frame.setVisible(true);
   	}
   }

Press the green run button to test drive our application on our host machine. You should get something that looks like this:

Error creating thumbnail: Unable to save thumbnail to destination

Congratulations! You have now written your first graphical program in Java.


Hint: Eclipse has many auto-completion features. Simply typing /:*<Enter> before a class creates a standard documentation block. Likewise, pressing <Ctrl>+<Space> provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials here.


Upload your Code onto your Overo COM

Now that you have a graphical program on Eclipse, its time to upload it onto your Overo COM. This will show you how to upload your code onto your Overo COM via ethernet connection. First, you will need to discover to IP Address of your Overo. To do this, see Eclipse on Gumstix for new users: Connect Your Gumstix. Once you have the IP Address of your Gumstix, it is time to export your Java Program onto your Overo COM.

  • Choose File -> Export from the drop down menu
  • Choose Remote Systems -> Remote File System and press Next
  • Expand the drop down for the HelloWorld project
  • In the bin folder choose HelloWorld.class

Note: We want to export the HelloWorld.class file and NOT the HelloWorld.java file. This is because our Overo COM can not compile a .java file. A .class file has already been compiled and is ready to run on a Java Virtual Machine, which our Overo COM will have after some necessary installations.


  • For Destination Folder, hit the Browse button
  • In the Browse For Folder window which will appear:
  • If you have already added a ethernet connection to your Overo COM, it should be in the drop down menu under Local
  • If it is not, hit New
  • Choose SSH Only
  • In the HOST Name, put the IP Address
  • Hit Finish
  • Under My Home choose Desktop and hit OK
  • Back in the Export window, hit Finish and Eclipse will export your program to your Overo!