Tuesday, November 8, 2011

Running the HelloWorld program

If your HelloWorld.class file is in:
C:\users\LavanniM\confucius

Open a command prompt, go to that directory and type:
> java HelloWorld

This will run the program and print "Hello World!" on your console

So what exactly happened?
* The command 'java' triggered the program java.exe (the JRE)
* It got the argument 'HelloWorld'
* It looked for HelloWorld.class in its CLASSPATH (more on CLASSPATH later)
* It looked for the 'main' method in HelloWorld.class
* It executed the 'main' method

No comments: