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.

Or you can just use "java class_name.java" command to compile and run a Java program in a single command. This feature is supported since JDK 9.

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:

herong$ javac Hello.java

To execute the program, use the "java" command:

herong$ java Hello
Hello world!

Or compile and execute the program in a single command:

herong$ java Hello.java
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 JDK

Compiling and Running Java Programs

 XML File DOM Parser - XmlDomFileParser.java

 JAXP API Module (java.xml.jmod) - Packages and Classes

 JAXP - XML Schema (XSD) Validation

 Xerces2 Java Parser - Java API of XML Parsers

 Using Xerces2 Java APIs

 XML Schema Language - Basics

 Introduction of XSD Built-in Datatypes

 "string" and Its Derived Datatypes

 "decimal" and Its Derived Datatypes

 "dateTime" and Its Related Datatypes

 Miscellaneous Built-in Datatypes

 Facets, Constraining Facets and Restriction Datatypes

 "simpleType" - Defining Your Own Simple Datatypes

 Complex Element Declaration

 Identity-Constraints: unique, key and keyref

 Assertion as Custom Validation Rules

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 Archived Tutorials

 References

 Full Version in PDF/EPUB