Compiling

  • Compiling creates a different .class file for each class.

Source Files

  • There can only be one public class per file.
  • The name of the source file must be the name of the public class.

Byte-code

  • Compiled java code in a machine independent form. To be run in a Java Virtual Machine (VM)

File extensions

  • *.java: source code
  • *.class: byte-code

Apps

javac myfile.java    # Compile myfile.java into bytecode: myfile.class
java myfile # Run myfile.class

Applets

javac myfile.java           # Compile myfile.java into bytecode: myfile.class
appletviewer myfile.html # Run the applet specified in the .html file.
appletviewer myfile.java # Run the compiled applet directly (if it has an embedded <applet> html tag)