Quick Links

Lesson 2: Getting Set-up to Write your Own Code

The first step to becoming a programmer is to set up your development environment.  In Lesson 1 we learned what a compiler is, and why we need one.  There are many free Java compilers available on the web.  For the sake of ease, we are going to be using an Integrated Development Environment (IDE) with a built in compiler.  This IDE is just a program we will use to write our very own programs, just like you may use Microsoft Word to write a letter.  My IDE of choice is the Eclipse IDE.  Eclipse is a completely free program we can use to write, compile, and run our Java code.  The Eclipse IDE has a very nice user interface, as well as numerous tools that will make it easier to write our code.  You can download it from the Links Section of this site Here.

Once you have downloaded Eclipse, simply extract the file someplace onto your computer.  If you don’t know where to put them “C:\Program Files\Eclipse” is as good of a place as any.  Also don’t forget to create a desktop shortcut so you can access it easily.  Now go ahead and open up Eclipse!

Once open, you want to click the far-right button “Work Bench”.  This will take you to the main eclipse work area, where we will spend all our time.  I think the best way to learn is to jump right in and run our first program, so lets get to it:

  1. Choose “File”->”New”->”Project…”
  2. Choose “Java”->”Java Project”
  3. Click “Next”
  4. Type a name for your project,  I will use “HelloProject” for this example – then click “Finish”

Now we have created our project.  This is simply a place where we can keep the code for the program we are about to write.  Each time we create a new program, we will first create a new project.

Now onto the actual code:

  1. Right click on your project name in the navigator bar on the left and choose “New”->”Class”
  2. In the “Name” field type “HelloWorld”
  3. A tab will open up in the main work area of the eclipse program with some code in it.  Delete it.
  4. Copy the “Hello World” code (Click the “View Source” Button)  example from the Examples page of this site, located here into the file we just created in eclipse.

Your Screen should now look like this:

The "Hello World" program in the Eclipse IDE

The "Hello World" program in the Eclipse IDE

Now for the good stuff:

  1. Save your file by choosing “File”->”Save” – When you do this, eclipse will automatically compile your source code into byte code.
  2. Click the Green “Play” button that is outlined in the red box in the picture above, this will run your program.
  3. View the output of your program in the bottom pane titled “Console”, it should read “Hello World.”

Lesson 1: Introduction to Programming

Computer programming or “coding” is the act of writing an accurate set of instructions that tell the hardware what to do.  This set of instructions is reffered to as source code, and can be read and editted by humans.  Even though source code is human readable, it is not written in english, french, or spanish.  Instead it can be written in any of the hundreds of programming languages in existance today.   For this site we are going to learn to write our source code in the Java programming language.

The good news is that it is actually much easier to learn a programming language than a foreign language (OK, that’s just an opinion.)  Programming languages have much less “words” that you need to be concered with, and generally involve much less typing.  Both programming languages as well as traditional languages have what we call syntax.  Java syntax can be thought of as the “rules” and “grammar” of the programming language.  For instance, in the English language we end our sentences with one of the following charecters: ( ?,  . , ! )  In the Java language, we end all “sentances” with a semicolon ( ; ).

So, if humans can read source code, what can computers read?  The answer is byte code. Byte code is the storied “computers can only talk in 1’s and 0’s” that you have probably heard of.  Humans typically will not deal with byte code.  So you may be asking yourself this question…If humans understand source code, and computers understand byte code, how can I write an accurate set of instructions for the computer, we don’t even speak the same language!  Easy, thats what the compiler is for.

The compiler is a computer program that will take your source code, and turn it into byte code that the computer can understand.  Think of the compiler as a translater, translating what you say in English into French, so that your friend from France can understand you.

Source code, the compiler, and byte code in action!

Source code, the compiler, and byte code in action!

New Terms Summary:

  1. Source Code – The human readable instructions that we will write, telling the computer hardware what to do.
  2. Syntax - The rules and grammer of a programming language which we will use when writing source code.
  3. Byte Code – The non-human readable code, which the computer understands.  This code is created by the compiler.
  4. Compiler – The “translator” which can convert the source code you write, into machine-understandable byte code.