Compile and Run Java Programs

This section describes 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.

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!

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

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

JDK (Java SE) Installation

 Downloading and Installing JDK

 Adding JDK "bin" Directory to Path Setting

 Downloading and Installing JDK on Mac

 Downloading and Installing JDK on Linux

Compile and Run Java Programs

 -cp or -classpath Syntax on Different Systems

 JDK Documentation Installation

 Microsoft SQL Server Express Edition

 Microsoft JDBC Driver for SQL Server

 Microsoft JDBC Driver - Query Statements and Result Sets

 Microsoft JDBC Driver - DatabaseMetaData Object

 Microsoft JDBC Driver - DDL Statements

 Microsoft JDBC Driver - DML Statements

 SQL Server - PreparedStatement

 SQL Server CLOB (Character Large Object) - TEXT

 SQL Server BLOB (Binary Large Object) - BLOB

 JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver

 JDBC-ODBC Bridge Driver - Flat Text Files

 JDBC-ODBC Bridge Driver - MS Access

 JDBC-ODBC Bridge Driver - MS SQL Server

 Archived Tutorials

 References

 Full Version in PDF/EPUB