Derby Hat

Building Derby





About This Document

These are the instructions for building the Derby jar files from the Derby sources.





Downloads

Before building Derby, you need to download the following:

Prerequisite Description
Derby Source If you are reading these instructions, chances are you have already unpacked a Derby source distribution. However, if you don't have the Derby source yet, get the development source tree from subversion by following these instructions.
Java Development Kit You need to install a Java 5 or later JDK. Probably, your machine already has this JDK. If not, Sun and IBM supply free JDKs for many machines.
Ant You need to install the Ant build tool, version 1.7.0 or higher. You can get Ant here.

If you are going to run the Derby tests, then you will need to download the JUnit test harness also:

Prerequisite Description
JUnit You need the JUnit test tool, version 3.8.2. You can get JUnit 3.8.2 here. Copy junit.jar into your Derby source tree, in the tools/java directory.





Simple Build

Before building Derby, cd to the root of your Derby source distribution. That is the top level directory which contains the LICENSE and NOTICE files. In addition, make sure that the version of Java which you are using is Java 5 or later. You can verify this by checking the output of the following command:


java -version

Now use the following Ant targets to build Derby.:

Target Description Command
clobber This target deletes all build artifacts.

ant -quiet clobber
buildsource This target compiles all source files needed for the Derby product. Don't be alarmed by all of the compiler warnings. We'll show you how to tidy those up later on.

ant -quiet buildsource
buildjars This target builds the Derby jar files.

ant -quiet buildjars

So, do this:


ant -quiet clobber
ant -quiet buildsource
ant -quiet buildjars

In order to build the Derby javadoc, you will need to run another target:

Target Description Command
javadoc This target builds the Derby javadoc. Be patient. The javadoc target takes a while.

ant -quiet javadoc


Verifying the Build

Run the sysinfo command to verify that the jars built correctly. This program will print out the Derby build information:


java -jar jars/sane/derbyrun.jar sysinfo

Testing Derby

If you want to build and run the Derby tests, make sure that you have downloaded the JUnit test framework. Then build all of the Derby sources, including the test classes:

Target Description Command
all This target compiles all Derby source files.

ant -quiet all

Putting all of this together, here's how you build the tests:


ant -quiet clobber
ant -quiet all
ant -quiet buildjars

To run the tests, consult the testing README.





Customized Build

You can customize the Derby build by setting variables in a file called ant.properties. The Ant tool looks for this file in your home directory. To find out where Ant thinks your home directory is, issue the following command and look for "user.home" in the output:


ant -diagnostics

Alternatively, or additionally, you can place properties in a file called 'local.properties' in the top of the source tree. Properties placed in this file have precedence over those in user.home/ant.properties.

Here are some Derby-specific variables which you may want to set in ant.properties:

Variable Description Default Example
deprecation Turn this flag off if you don't want to see pages of warnings generated when the compiler encounters references to deprecated methods.
on

deprecation=off
sane By default, this variable is set to true. This builds extra assertion and debugging logic into Derby classes. If you set this variable to false, then the Derby jar files will be smaller and Derby will run faster. During typical development, you will leave this variable set to true. However, this variable is set to false when building official Derby releases.
true

sane=false


Advanced Build

Derby is supposed to run in all of the following environments:

Platform JDBC Level
Java 6 JDBC 4
Java 5 JDBC 3
JDK 1.4.2 JDBC 3
Small Device (CDC/FP 1.1) JSR169

The default Derby build does NOT necessarily verify that the compile-time contract is satisifed for any of these platforms. To get compile-time checks, you need to make sure that the following variables are set correctly. To see the values which the Derby build uses for these variables, build Derby after setting the following debug variable in your ant.properties:


printCompilerProperties=true

Here are the variables which determine whether the Derby build enforces compile-time contracts for the supported platforms:

Platform Compiler Variable Description Default Value
Java 6 java16compile.classpath The Derby build tries to find a Java 6 JDK on your machine. The build fails if it can't find a Java 5 or Java 6 JDK. The list of jars in your Java 6 JDK if the build can find them. Otherwise, classes/stubs/jdbc4:${java15compile.classpath}
Java 5 java15compile.classpath The Derby build tries to find a Java 5 JDK on your machine. The build fails if it can't find a Java 5 or Java 6 JDK. The list of jars in your Java 5 JDK if the build can find them. Otherwise, classes/stubs/jdbc3:${java16compile.classpath}
JDK 1.4.2 java14compile.classpath The Derby build tries to find a 1.4 JDK on your machine. Note that Sun and IBM supply free 1.4.2 JDKs for many machines. The list of jars in your 1.4 JDK if the build can find them. Otherwise, ${java15compile.classpath}:tools/java/xalan.jar:tools/java/serializer.jar
Small Device (CDC/FP 1.1) jsr169compile.classpath This should be set to the list of small device libraries on your machine--if you have them. That is, the CDC/FP 1.1 jars and the jsr169 jar. To get a set of small device libraries, see Sun's instructions or download IBM's WCTME 5.7. classes/stubs/jsr169:${java14compile.classpath}

The preceding variables are mandatory for the Derby build. For Mac OS X, Solaris, and many Linux and IBM machines, Derby can figure out where the JDKs live and can therefore set the preceding variables to reasonable values if you don't set them. For other platforms, the Derby build may not be able to figure out where the JDKs live. On those platforms, you can help the Derby build by setting the following optional variables in ant.properties:

Compiler Variable Description Default Value
j14lib If you set this variable to be the directory which contains your 1.4 jars, then the Derby build will set java14compile.classpath to be the list of jars in that directory. Optional variable. No default value.
j15lib If you set this variable to be the directory which contains your Java 5 jars, then the Derby build will set java15compile.classpath to be the list of jars in that directory. Optional variable. No default value.
j16lib If you set this variable to be the directory which contains your Java 6 jars, then the Derby build will set java16compile.classpath to be the list of jars in that directory. Optional variable. No default value.

Here, for instance, are some sample settings of classpath variables (you should omit the \ continuation markers, which are included in these examples simply to improve readability):


java16compile.classpath=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/charsets.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/classes.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/dt.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/jce.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/jconsole.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/jsse.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/laf.jar: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/management-agent: \
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/ui.jar

jsr169compile.classpath=/Users/myself/sw/phoneME/phoneme_advanced_mr2/lib/btclasses.zip: \
    /Users/myself/sw/phoneME/phoneme_advanced_mr2/lib/basis.jar: \
    /Users/myself/sw/jsr169Support/jdbc.jar