Program
class Welcome {
// A java program will start from here.
public static void main(String args[]) {
System.out.println(" Welcome to Java-Samples!!! ");
}
}
Compilation
After we have written our program we need to compile and run the program. For that we need to use the compiler called javac which is provided by java. Go to the command prompt and type the file name as shown here.
c:\>javac Welcome.java
The javac compiler will create a class file called Welcome.class that contains only bytecodes. These bytecodes have to be interpreted by a Java Virtual Machine(JVM) that will convert the bytecodes into machine codes.
Execution
Once we successfully compiled the program, we need to run the program in order to get the output. So this can be done by the java interpreter called java. In the command line type as shown here.
c:\>java Welcome
So the output will be displayed as
Welcome to Java-Samples!!!
Welcome to Java-Samples!!!
Post a Comment