Using Eclipse to Write HelloWorld in Java for the Overo

From Gumstix User Wiki
Revision as of 09:57, 27 July 2010 by JustinC474 (Talk | contribs) (Created page with '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 y…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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.