XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.11

Compiling and Running Java Programs

This section describes a tutorial example on how to compile and run Java programs.

When JDK is installed on your machine, it provides two commands for you to compile and run Java programs.

  • "javac class_name.java" - Compiles a Java program stored a file named with the program class name.
  • "java -cp . class_name" - Runs a compiled Java program. "-cp ." specifies the current directory as the class path.

Let's try these commands with a very simple Java program. Use NotePad to enter the following Java program into a file called Hello.java:

class Hello {
   public static void main(String[] a) {
      System.out.println("Hello world!"); 	
   }
}

Then compile this program in a command window with the "javac" command:

C:\>\progra~1\java\jdk1.6.0_02\bin\javac Hello.java

To execute the program, use the java command:

C:\>\progra~1\java\jdk1.6.0_02\bin\java Hello
Hello world!

Congratulations, you have successfully entered, compiled and executed your first Java program.

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

Java API for XML Processing - JAXP

 What Is JAXP?

 Downloading and installing Java SE 1.6 Update 2

Compiling and Running Java Programs

 XML File DOM Parser - XmlDomFileParser.java

 JAXP - XML Schema (XSD) Validation

 XML Parser API - Xerces2 Java Parser

 XML Schema Language - Basics

 XML Schema Built-in Datatypes

 Complex Element Declaration

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2009
Compiling and Running Java Programs