Lesson 2: Let’s Say Hi!

Yo yo yo! You guys ready for some actual coding now?  Of course we’re going to start with “Hello World!”

First, open up Eclipse. It will ask you for a workspace location.  I just used the default and selected the “always use this and do not prompt” option so it doesn’t come up every single time we open Eclipse.


So we have Eclipse open and are ready to write our very first Java program! Hopefully your screen looks similar to this because this is how mine looks when I launch it.  You will not have the “Tutorial1” item displaying on the left, that’s another project that I started.


To begin, you’re going to want to click on the dropdown arrow on the “New” icon and then select “Java Project.”
You can also click file > new > Java Project



When you’re creating your project, give it a name (red box below) and then click finish.  Since we are doing the HelloWorld program to begin, that’s what I named my project.


Cool, so we have a project! When you expand your project folder, there is absolutely nothing in it other than the JRE Libraries and a SRC folder. So I guess there are things in it, but no .java files yet.

We want to add a CLASS file to the SRC folder and to do that, take a look at the screenshot below.

We have two options (personal preference):

  1. Right click on the src folder > new > class
  2. Click the “new class” button on the toolbar.


Creating the class for this program is fairly strait forward.  Just need to give it a name, and then check the box I pointed out below.

This will create a main() method in the new file we are creating.  This just helps save us some typing.  There needs to be a main() method in every program you create.  It’s basically the entry point.


Now we’re jiving! Got some actual Java code down on the page. We’re basically pros right?

By the way, the line with the // is a comment.  This means that anything after it is just a hidden comment in the program and doesn’t actually do anything when the program is compiled.  You can leave this or take it out, it’s your choice.   I will highlight commenting in a future discussion, but it’s basically a way for programmers to notate what a piece of code is doing so future developers looking at the code know what’s going on.


So we have our main() method and now we want to print some words to the console.  To do this, we want to add a line of code inside the main() methods {} (curly brackets).

System.out.println("Hello World!");

The full code should look like the snip below:


SHORTCUT: something nifty about Eclipse is that it has some built in shortcut keys to help you build out code that is commonly used. To get a line of System.out.println(“”); all you have to do is type sysout on a line, and then hit CTRL+SPACE and it will auto complete.
SHORTCUT 2: To delete a line quickly, you can use CTRL+d – this deletes the entire line that your cursor is on which is a quick way to clean stuff up.  If you highlight a section and use the shortcut, it will delete the entire section.

Once you have the code written above, make sure to save your project.  You can use CTRL+s or you can click the floppy drive save image in the tool bar, or click file > save.

Now we want to run our newly coded program!

This is super simple and can be accomplished by clicking the green play button I’ve pointed out below.

Once you click this, Eclipse may prompt for you to save the file, obviously do this.   Then in the console window at the bottom of the page, you can see the words you typed in!


Your turn!

Try implementing this and printing your own message to the console window.

We’ve written our first Java program and are now officially Java Developers! Wooooo!

See you knowledge seekers on the flip side!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s