Compiling and Execution


  • Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java as shown in the HelloWorld example in the HelloWorld chapter.
  • Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.
  • Run Command Prompt (found under All Programs/Accessories in the Start menu).

Type:

1. C:\cd \mywork

This makes C:\mywork the current directory.

2. C:\mywork>; dir

This displays the directory contents. You should see HelloWorld.java among the files.

3. C:\mywork> javac HelloWorld.java

This runs javac.exe,the compiler. You should see nothing but the next system prompt...

4. C:\mywork>; dir

javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.

5. C:\mywork> java HelloWorld

This runs the Java interpreter. You should see the program output: Hello, World!


Popular posts from this blog

Naming Conventions

if..else..if Loader

Nested if..else Statement