Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

'javac' - The Java Program Compiler

This chapter describes the Java compilation tool 'javac'. Topics include listing of 'javac' options, specifying class path with '-classpath', specifying source path with '-sourcpath', processing 'import' statements, generating debugging information with '-g'.

'javac' - Java Compilation Command and Options

Compiling Hello.java - My First Java Program

Option '-classpath' - Specifying Class Path

Option '-sourcepath' - Specifying Source Path

Option '-d' - Specifying Output Directory

Two Types of 'import' Statements

'import' Statements Processed by 'javac'

Option "-g" - Controlling Debugging Information

Conclusions:

  • "javac" is the standard compiler in JDK.
  • "-sourcepath" specifies places where to search for source definitions of new types.
  • "-classpath" specifies places where to search for class definitions of new types.
  • Two types of "import" statements behave differently with "javac".
  • Never distribute your class files with debugging information in them.

Dr. Herong Yang, updated in 2008
'javac' - The Java Program Compiler