The best way to learn Java programming language fast is by learning from example programs and building your own programs. The javatheprogram.blogspot.com can be used to achieve this objective. The javatheprogram.blogspot.com site tries to provide you useful programs as many as possible that can help you learn Java fast and then you can build your own programs. You will find link to each program from the right navigation bar.
Compile and Run Java program
To compile and Run a Java program. You need to install JDK. The latest JDK
version is 7. You can download and install JDK from
http://java.sun.com website. When you successfully install, you will have javac command to compile and java command to run the program. Below are steps that may help you compile and run Java program:
- Save the program in a folder. The file name and the class name are case-sensitive and must be the same.
- From command prompt window, change to the folder that contains the java file you just saved.
- Type javac filename (extension java) to compile the program. If any error is shown, read it and correct the source code and to run the program type java filename (without extension).
For example, The Java file name HelloWorld.java is saved in the D:\myprogram folder. To compile and run the HelloWorld program in that folder, follow the steps below:
- Type cmd in the search box near shutdown button (Windows 7) to open the prompt window
- When the command prompt window is active, type D: to change to the D drive
- Then type cd myprogram to enter the myprogram folder
- When you are in myprogram, type javac HelloWorld.java to compile the program. When you successfully compiled the program the HelloWorld.class file is created in the same folder.
- Type java HelloWorld to run the program.
![]() |
compile and run Java program |