How to Get Started in Java Programming

Posted by

If you have decided to learn an object oriented programming language like Java, you might be exited and want to start right away. In this article I will show you how to make your first simple program and run it on your computer.

You need 3 things:

  • A compiler
  • A good self-study book or a course
  • Persistence

There are three editions of Java. SE, ME and EE. You want the SE which is Standard Edition. The others are Mobile Edition and Enterprise Edition.

After you have downloaded and installed the JDK, you need to make one small change in your PC settings. You want the compiler to be accessible from the command prompt.

To do that you have to add the location of the program files to the PATH variable.

1: Click Start → Control Panel → System (assuming you use Windows XP)

2: Click Advanced → Environment Variables.

3: Find the location of the bin folder in your installation. You can do this by using the Explorer. It’s a good idea to copy the path from there. It might be: “C: ProgramsJavajdk1.6.0_23bin”

4: Add the location to the PATH variable. You probably already have a PATH variable, so choose Edit for that one add a semicolon in the end and the location you copied in step 3

You can test if it is working by opening a command prompt and type JAVAC. This should make the compiler run. Since you did not give a file names as parameter, it just shows you the help file.

Now that you have the compiler working, it is time to make your first Java application. Open notepad or any other simple text editor and type in the following text exactly like shown here.

public class HelloWorld
{public static void main (String [] args)
{System.out.println (“Hello World!”);}}

Then save the file as “” in the folder where you want to keep you Java projects. Make sure you do not save it with the.txt extension, even though it is a text only file.

Go back to your command prompt and type:


This will tell the Java compiler to translate the file you just made. If there is no errors you will now have a file called “HelloWorld.class”. This is the byte code version of your program. It can not be run as you would do with an executable program file. Instead you need the Java interpreter. You can test your program with the command:

java Helloworld

Note that you do not need the.class extension. You should now get the output from your program:

Hello World!

Congratulations! You have now made and tested your first Java program. I recommend you also try to make a small change, to get a feel of how things work. Of course it is difficult now, as most of the code does not make much sense when you do not know Java yet. But you can change the text between the quotation marks to make the program print a different text.

To get to learn how to write java programs, you will need a course or a good book. There are many available free books on the matter.

One suggested title is Introduction to Programming Using Java by Professor David J. Eck, a free, on-line textbook on introductory programming, which uses Java as the language of instruction.

Leave a Reply

Your email address will not be published. Required fields are marked *