Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » Java in the database » Tutorial: Using Java in the database

 

Lesson 1: Compiling a Java program

The first step to using Java in the database is to write the Java code and compile it.

Prérequis

Install a Java Development Kit (JDK), including the Java compiler (javac) and a Java Runtime Environment (JRE).

This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Using Java in the database.

Contexte et remarques

The database server uses the CLASSPATH environment variable to locate a file during the installation of classes.

 Task
  1. Open a command prompt and go to the %SQLANYSAMP16%\SQLAnywhere\JavaInvoice folder.

    cd %SQLANYSAMP16%\SQLAnywhere\JavaInvoice
  2. Compile the Java source code example using the following command:

    javac Invoice.java
  3. This step is optional. Before starting the database server, make sure that the location of your compiled class file is included in the CLASSPATH environment variable. It is the CLASSPATH of the database server that is used, not the CLASSPATH of the client running Interactive SQL. Here is an example:

    SET CLASSPATH=%SQLANYSAMP16%\SQLAnywhere\JavaInvoice

Résultat

The javac command creates a class file that can be installed into the database.

Suivant

In the next lesson, you select a Java VM which will be used to run your Java code. Proceed to Lesson 2: Selecting a Java VM.