OO Programming with Java


Hello World !

  1. Open a terminal where the preceding file is saved and enter the following commands:
javac Hello.java #1 - compilation (syntax error ?)
ls               #2 - bytecode (.class)
java -cp . Hello #3 - execution (by a Virtual Machine VM), cp="classpath"
> Hello World !

The file is compiled with (1) what generates bytecode for the VM saved in Hello.class. This latter can be checked with (2). Then, the bytecode is run with (3).
Nb. With the last version of Java, only the third line is necessary (bytcode is obtained "on the fly").

java -cp . Hello.java

4 - 17