Begin Programing Computers with Java

Anyone can program computers for free. Even if you have absolutely no experience and no idea how to start programming, you can learn to program computers. I started out knowing nothing about computers, and now have 20 years of professional programming experience on top of 10 more years of programming for fun.

You can have the same success I’ve had at programming computers. You only need to start learning, and consistently practice what you learn.

Picking a Computer Language

The first step to programming is choosing a language. Pick a language that can do everything you dream of making a computer do. That way you don’t have to learn a new language just because you want to start a new project.

The big three computer programming languages are Java, C#, and C++. Experienced programmers on all three of these languages can make their computers do anything that other languages can do. That includes: game creation, web application creation, hardware memory access and manipulation, and interfacing with other languages. If you’re interest is programming computers professionally, then there are plenty of jobs for people that know Java, C#, or C++.

C++ is not as popular as it used to be, because it makes many easy tasks hard. C++ requires excessive fine tuning for things like memory management. C++ lives in the realm of low level computing, intensive computer graphics, hardware drivers, and custom memory optimization.  It’s a great language if you don’t mind a long difficult learning curve.

C# is mostly a Windows only language. If you never ever ever … ever will want to program for anything but Windows, C# is a great choice. True gurus can make C# work on other types of computers, but for beginning users, that’s a lot of distraction from the process of learning the language. Besides, windows lost the platform wars with the advent of mobile computing. Most computers and devices won’t run C# based programs.

Java isn’t a silver bullet. However, it builds and runs almost as many places as C++ without nearly as much aggravation for beginners. Thanks to Google, Java even compiles down to JavaScript for running HTML5 web applications. Of the big three computer languages, Java combines an easy learning curve (like C#) and massive acceptance across computing platforms (like C++).

As you become experienced at programming computers, you may pick up several computer languages. In the beginning, it’s easier to stick to one language. For this tutorial, I’ve chosen Java.

Java SE Development Kit (JDK)

The first step to learning Java is getting the free developers kit. Java comes in two flavors, the normal version and the developer’s version. The developer’s version has extra tools and libraries needed to create programs for normal users.

Visit oracle.com to get the java developers kit (JDK). Currently, the link is the JDK download at:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

You won’t need the Server JRE or JRE, just the Java SE JDK download. Go ahead and grab a new JDK and follow Oracle’s installation instructions for your computer.

JDK Download Screen
Download the JDK for your computer. Mac OS X, Windows, and Linux versions of the JDK are available.

Integrated Development Environment (IDE)

The second step to learning Java is installing one of the many free environments. Computer programming environments are called integrated development environments, or simply IDEs. Java has a whole bunch of good ones.

My favorite Java IDE is Eclipse. It’s free, and can handle tons of languages besides Java. That means that when you venture out into the world beyond Java, you don’t have to give up your familiar IDE.

Grab a copy of Eclipse IDE for Java Developer from eclipse.org. Make sure you install the one meant for your computer.

Eclipse Download Screen
Download the right version of Eclipse for you computer. If you’re not sure which one is right, make your best guess. If you’re guess is wrong, try again.

Your First Java Program

Open up your shiny new Eclipse IDE for Java Developers. In keeping with tradition, you’ll start by making a “Hello World” application. Don’t let all the bells and whistles of Eclipse scare you. You’ll learn to love them eventually, but for now their’s a whole lot of windows, buttons, and menus. They can be distracting and intimidating. Don’t stress.

If Eclipse asks for a path to your workspace, just select the default location, or create a folder somewhere and select that folder. A workspace is just a directory that holds your work. Nothing mystical about it.

The first time you open Eclipse, you see the Welcome screen. You can explore this screen any time you want from the menu by selecting Help->Welcome. For now close it by clicking the X on the Welcome tab.

Welcome Screen
Eclipse’s Welcome screen is available from the Help menu any time you want to explore it.

After closing the Welcome screen, you will see a completely empty Eclipse workspace. It looks something like the following.

Empty Eclipse
Empty Eclipse workspace. Think of it as a blank sheet of paper.

Create a new Java project by selecting File->New->Java Project from the menu. Set the project name to helloworld in the Project name field of the New Java Project dialog, then click Finish. Now you should see a new Java project named helloworld in the Package Explorer on the left hand of your workspace.

 

Package Explorer
The Package Explorer explorer holds folders representing Java projects. In our case, only the “helloworld” project is visible.

Select the src folder in the helloworld Java project. Create a new Java class by selecting File->New->Class. Name the class HelloWorld (with no spaces). Make sure that public static void main(String[] args) is checked. Then click Finish.

You should now have a HelloWorld.java file displayed in the center of your workspace.

Java Hello World Class
You should see the Java HelloWorld class in the center viewable area of Eclipse.

Find the TODO comment:

// TODO Auto-generated method stub

 

Replace it with a command to print Hello World!

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

 

The entire HelloWorld.java file should read:

package helloworld;

public class HelloWorld {

   public static void main(String[] args) {
	System.out.print("Hello World!");
   }
}

 

From the menu, select Run->Run. At the bottom of the workspace, a new tab should open called Console. In that console you should now see the words, Hello World!

Summary

The big three computer programming languages are C#, C++, and Java. C# is somewhat limited to Windows computers. C++ is complex, but great for demanding low-level programming. Java combines the platform independence of C++ and the ease of use found in C#.

To program Java, download a JDK from oracle.com and an Eclipse IDE for Java Developers from eclipse.org. Choose a folder for your workspace, create a new project, and create a class with a main method to program in. Setting up and running a simple Hello World application takes little effort at all.