Programming 101 - How to Download Eclipse and Code a Basic “Hello World” Print Statement in Java

By: Andrew DePero

What you will be learning

If this is your first time coding, you will be learning the very basics on how to initialize a program in Java. This guide takes you through all the steps you will need to get set up with an IDE, or a program with an interface that you can write and run code, as well as how to set up a very basic program that prints something simple, like “Hello World.”

Why learn basic programming?

Computers are becoming increasingly prevalent in all aspects of society, even outside the realm of programming and computer science. Having even a basic understanding of some of the concepts of programming can make you stand out, and may give extra opportunities and promotions in any career.

Why learn to use Eclipse?

Eclipse is a very common IDE used by beginning and advanced software developers. There’s different versions for different computing languages, so learning it can be beneficial if you want to switch languages while keeping a familiar interface. While it may be a little confusing to get used to, Eclipse offers many extra tools and functions to make certain programming aspects easier.

Materials

Windows or Mac laptop or desktop with a JDK installed. This is the java compiler and your programs cannot run without it.

**NOTE** The following demonstration is for Windows users. Mac should be similar, and the code is the same, but there may be differences in installing and running programs.

**NOTE** If you already have eclipse installed on your computer and have selected your working directory, skip to heading #3.

1. Downloading Eclipse Installer

Note: Eclipse may take a long time to install.

  1. Go to https://www.eclipse.org/downloads/ (alternatively you can just Google “Eclipse download” and you’ll get to the same place).
  2. Click on the download link and make sure you download the right file for your operating system.
  3. Run the Eclipse downloader.
  4. Accept all license agreements and terms and continue until Eclipse downloads.
  5. If you are prompted to select a type of Eclipse, select “Eclipse for Java Developers.”
  6. Once finished, open Eclipse.

2. Getting Eclipse Set Up

This section goes over the basic startup procedure when you open Eclipse for the first time. You will be asked to choose a directory for your workspace. The workspace is where all of your project files will be stored. Then it takes you to a welcome screen that isn’t entirely useful, so if you want, you can uncheck the box in the bottom right hand corner to open straight to the workbench in the future.

  1. Choose a working directory, when prompted. You could make a folder in your documents sections for it, or anywhere if you prefer.
  2. Exit the welcome screen when it pops up by either clicking the “Workbench” button in the top right or by closing the page to enter the workbench.

3. Getting Your Program Set Up

This section goes over creating a project in Eclipse. Projects are made up of the file(s) that are used to run your code.

  1. Click the dropdown arrow next to the white board with a “+” icon in the upper left-hand corner and select “Project.”

  1. Double click on or press the arrow next to the “Java” folder and select “Java Project” and then click “Next >”

  1. Name your project “Hello World”.
  2. Click “Finish” to create the project.

4. Creating Your Class

Now that your project is set up, you now need to create a class where you will actually type out your code. This is the code that actually runs when you run your program. When naming classes, it’s important to note that the name for your class cannot contain spaces or other strange characters, and it’s common practice to start with a capital letter and use lowercase letters, and start new words with capital letters.

  1. Right-click on your project in the bar on the left, hover over “New”, then click on “Class” about halfway down.

        

  1. Leave everything the way it is, except the “Name” section a little ways down from the top.
  2. Name your class “HelloWorld” (without the space).

  1. Click “Finish” and you should see that there is now text in the coding section of your interface that says: “public class HelloWorld {”

5. Writing Your Code

Now that your project and class are set up, it’s finally time to write your code. It’s important to note that computer language is extremely specific, and must be entered exactly as it appears. Make sure to pay extremely close attention to capitalization and punctuation. One mistake and your program will not work properly.

  1. Move your cursor to the empty line in between the opening and closing brackets and type the following phrase to create your main method (use the characters [ and ] after “String”):

public static void main(String[] args) {

  1. Press enter and a closing bracket “}” should appear automatically appear on the line beneath your cursor. If for some reason there is not, make sure each opening bracket has a matching closing bracket.

  1. Type the phrase in the empty line in between the opening and closing brackets of the main method (with a capital “S” in system and a lowercase “LN” after “print”):

System.out.println(“Hello World”);

  1. Click on the plain green circle button with the triangle in it along the top bar.

  1. Select to save your project before running, when prompted. You can check the box to make Eclipse do this by default.

  1. Watch as the computer prints “Hello World” into the bottom section of the screen.

Congratulations! You have successfully written a Java program. Now you can experiment and learn about other cool things you can do.