class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
Type the above code using your favorite plaintext editor in the folder you want with the name HelloWorld.java Bring up a shell, or "command," window. You can do this from the Start menu by choosing Run... and then entering
cmd
. To compile your source file, change your current directory to the directory where your file is located (in my case is c:\) , if you enter dir
at the prompt, you should see your source file.Now you are ready to compile. At the prompt, type the following command and press Enter. The compiler has generated a bytecode file,javac HelloWorldApp.java
HelloWorldApp.class
. At the prompt, type dir
to see the new file that was generated. Now that you have a .class
file, you can run your program. At the prompt, type the following command and press Enterjava HelloWorldAppThe following image depict the above steps.

No comments:
Post a Comment