The Bear Minimum - Simple programs using "Hello World!"

Whenever you try learning a new program language, I guarantee that you'll run into the phrase "Hello World," among others like "Foo Bar." HelloWorld is a simple application that prints out a phrase to the user and provides an experienced programmer the syntax and grammar on how to use this language. In some ways, its referred to the simplest application you can write for a programming language.

Below we'll create three different HelloWorld programs.

In order to create this program in Java we'll have to create a file named Please use a text-editor such as NotePad or Vi to do so. Within this file, we'll write out some java code that will allow us to print the message to the user.

Here are the contents:

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

Before you can run this file, you will have to compile it first. Compiling takes the code that you've written and converts it into a language that the machine (Java Virtual Machine) can understand. Before you compile, go to the directory that contains the file with your command-line tool. If you saved the file under "c:/myprograms" you can type "cd c:/myprograms". Make sure that the file exists and has the ".java" extension. You can do this with the "dir" command.

To compile type:

If your code is valid, it will create a file named HelloWorld.class and not prompt you with any errors.

To run the program type:
java HelloWorld

Notice that when compiling you must pass it the filename and when you try to run the program you only use the name of the class.

To create a HelloWorld app in JavaScript, let's create a new file named HelloWorld.html. Within this file use the following:
<script type="text/javascript">
document.write("Hello World!");

Make sure that the editor that you're using saves the html file without adding any extra markup. Some will manipulate the characters above in order to make it "readable" to humans rather than executing it as code.

To run this code, open HelloWorld.html in any web browser such as Internet Explorer or FireFox.

In a file named "" type:

print "HelloWorld!"

Then on the command-line, within the same directory as, run the code with the following command:


Easy ain't it?!