Setting the Module Path or Class Path for Java Development

Compiling any Java application requires the appropriate JARs to be in your module path or class path.

Java Development Kit

Before running a Java program that loads any of the TimesTen JDBC drivers, configure the JDK library file and path in your Java runtime environment. In Java, class path and module path both tell the JVM and compiler where to find code.

For JDK 11, 17, 21, and 25, the TimesTen JDBC JAR is timesten_home/install/lib/ttjdbcjdk_version.jar, where jdk_version indicates the JDK version, 11, 17, 21, or 25, for example, ttjdbc25.jar for JDK 25. The JAR is also packaged as a Java module with the Java module name, timesten.jdbc, so you can use it for module compilation.

The tables below summarize the supported ways to compile and run applications, including both modular and non-modular usage. The options differ slightly between JDK 25 and JDK 11-21.

Table 1-1 JDK 25: Using the TimesTen JDBC Module

Option Description Compile Command Run Command

Option 1: Modular application

Add ttjdbc25.jar to the module path.

javac --module-path <progname>.java module-info.java

where:

  • $module_path is timesten_home/install/lib/ttjdbc25.jar:existing_path_to_modules is the name of the application you want to compile.
  • <progname>.java is the name of the application you want to compile.
  • module-info.java describes the module to include in the application.

The following example shows a sample module-info.java file that requires the timesten.jdbc module.

module my.testmodule {
     requires java.sql; 
     requires timesten.jdbc;
...
}
java --module-path $module_path --enable-native-access=timesten.jdbc" --module $name_of_module/$classname
where:
  • $module_path is timesten_home/install/lib/ttjdbc25.jar:existing_path_to_modules
  • $name_of_module is the module defined in module-info.java.
  • $classname is the complete classname including namespace (package name) where the main execution is.

Option 2: Non-modular or mixed application

If your application is not a module or it uses JARs that are not packaged as Java modules, add the JARs that are modules to the module path and continue to use classpath for the rest of the non-module dependencies.

javac -cp $CLASSPATH --module-path $module_path …

where $module_path is timesten_home/install/lib/ttjdbc25.jar:existing_path_to_modules.

java -cp $CLASSPATH --module-path $module_path --enable-native-access="timesten.jdbc" …

Note:

Every time you want to compile a modular application the classes must have a package name ($classname ).

Table 1-2 JDK 11, 17, 21: Using the TimesTen JDBC Module or Classpath

Option Description Compile Command Run Command

Option 1: Modular application

Add ttjdbcjdk_version.jar to the module path.

javac --module-path $module_path …

where $module_path is timesten_home/install/lib/ttjdbcjdk_version.jar:existing_path_to_modules.

java --module-path $module_path --enable-native-access="timesten.jdbc" …

For JDK 11, exclude --enable-native-access:

java --module-path $module_path …

Option 2: Non-modular or mixed application

If your application is not a module or it uses JARs that are not packaged as Java modules, add the JARs that are modules to the module path and continue to use classpath for the rest of the non-module dependencies.

javac -cp $CLASSPATH --module-path $module_path …

where $module_path is timesten_home/install/lib/ttjdbcjdk_version.jar:existing_path_to_modules.

java -cp $CLASSPATH --module-path $module_path --enable-native-access="timesten.jdbc" …

Option 3: Legacy classpath

Add ttjdbcjdk_version.jar path to the classpath.

javac -cp $CLASSPATH …

where $CLASSPATH is timesten_home/install/lib/ttjdbcjdk_version.jar:existing_classpath.

java -cp $CLASSPATH …

Java Environment Variables in Oracle TimesTen In-Memory Database Installation, Migration, and Upgrade Guide discusses the CLASSPATH setting for compiling Java applications in TimesTen.

JMS/XLA Applications

Compiling any JMS/XLA application requires the following to be in your classpath:

JMS Type Classpath Entries
Jakarta timesten_home/install/lib/timestenjmsxla.jar timesten_home/install/lib/orai18n.jar

In Installing TimesTen and Supported Java Components, you downloaded the Jakarta JMS JAR. You need to add the location of the JAR to your classpath:

download-directory/jakarta.jms-api-3.1.0.jar
JavaX timesten_home/install/lib/timestenjmsxla.jar timesten_home/install/lib/orai18n.jar timesten_home/install/3rdparty/jms1.1/lib/jms.jar

timestenjmsxla.jar is for use with both Jakarta JMS and JavaX JMS, but note download-directory/jakarta.jms-api-3.1.0.jar in the classpath determines Jakarta JMS and download-directory/install/3rdparty/jms1.1/lib/jms.jar in the classpath determines JavaX JMS. If both JARs are in the classpath, TimesTen defaults to Jakarta JMS.

When running your modular JMS/XLA application, you can add the above timestenjmsxla.jar path to the module path and add the module name timesten.jdbc to --enable-native-access option.

java --module-path $module_path --enable-native-access="timesten.jdbc,timesten.jmsxla"

where $module_path is the module path that includes timesten_home/install/lib/ttjdbcjdk_version.jar and timesten_home/install/lib/timestenjmsxla.jar:existing_path_to_modules.

Classpath Entry for ttenv

Use the appropriate ttenv script to set your environment, as discussed in Setting the Environment for Java Development.

Note:

  • For each TimesTen instance, the timesten_home/install path is a symbolic link to installation_dir, where TimesTen is installed.

  • On Windows, there is only one TimesTen instance per installation, and timesten_home refers to installation_dir\instance.