“Drive slow and enjoy the scenery – drive fast and join the scenery” Douglas Horton
The purpose of this section is to simply compile and run a program just to see how this process is done.
-
Open a Notepad in your system.
-
We need a source code to run. So for now just copy and paste the
code below in the Notepad:
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Suffice it to say, the program above simply sends the message “Hello World” to the screen.
Basically when you ran the program, you’ll see the message on your screen.
Now, save the file with the name Main and the extension of .java. So at the end you’ll have a file named Main.java in your program.
Note: because name of the class was Main we need to set a file with the same name. But if the name of the class was something else, we would need to change the name of the file to match the name of the class.
Also all Java source codes have the .java extension.
-
Now open the command prompt and go to the directory where your
file is stored and then type this command:
javac Main.java
