java interpreter Tutorials - My First Java Program Tutorial >
How Java Works:
The code that you write in your java program is converted by a java compiler into a binary program consisting of bytecode. Bytecodes are machine instructions for the java virtual machine.
When your java program is executed(compiled) a java program called the java interpreter carries out a number of checks on the bytecode i.e. (make sure it is safe to execute). It then executes the actions specified in the Java Virtual Machine.
The major benefit of using bytecode is that its free from hardware restrictions thus allowing your programs to run across almost all Operating Systems.
Creating your first program?
A Java a program consist of a collection of one or more classes. Java source code always is stored in files with extension .java. Java is case sensitive so remember when compiling your files you need to use the correct case(upper or lower).
Ok Let's create our first Java Program
(1) Open Notepad and type out the following
//OUR FIRST PROGRAM.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
(2) Save your java program With .java Extension. You should always use the class name as your filename. Example you should save the above example as HelloWorld.java. (Remember java is case sensitive)
(3) Next we need to compile our Java program by issuing the following command in our DOS prompt
javac HelloWorld
HelloWorld.java is now converted into a bytecode program -> HelloWorld.class. (You will see this file located beside your .java file on you file system).
(4) Finally to execute our java program we issue the java command in the DOS prompt.
java HelloWorld.
The bytecode found in HelloWorld.class is analyzed and executed by the java interpreter and the output from our program should be.
Output = Hello World.
![]() |
![]() |

