To compile the FairCom DB API Java tutorials from the command-line, follow these steps:
This document is oriented toward a Windows command-line environment. The principles are the same for all other environments, such as Linux/Unix.
Note: The FairCom FairCom DB API Java API requires a Java Development Kit (JDK) be installed on your computer. A Java Runtime Environment (JRE) is not sufficient. Note also that the Java compiler (javac.exe) must be in your system path. On Windows, this file typically resides in a path similar to C:\Program Files\Java\jdk_______\bin, and can be set with a command similar to the following: set path=%path%;C:\Program Files\Java\jdk_______\bin
Building and running the tutorials with the batch file:
Move to the drivers\java.nav\tutorials\cmdline directory and execute the BuildTutorials.bat file for Windows, or make for Linux. This file will determine if a Java JDK is installed, and if it is 32-bit or 64-bit. It will then compile all of the tutorials included for this tutorial. Lastly, it will execute each tutorial for you, so be sure you have the FairCom DB SQL Server running on your system.
By default, the output of the first tutorial will look similar to this:
INIT
Logon to server...
DEFINE
Open table...
Add fields...
Create table...
MANAGE
Delete records...
Add records...
Display records...
1000 Bryan Williams
1001 Michael Jordan
1002 Joshua Brown
1003 Keyon Dooling
DONE
Close table...
Logout...
Press <ENTER> key to exit . . .
Troubleshooting
This section lists some errors you may encounter when compiling and running the tutorials using the batch / make file.
JDK not found! Please set environment for the Java JDK.
On Windows, this means that the Java compiler (javac.exe) is not in your system path. Follow the instructions above to put javac.exe in your path.
ERROR: [133] - c-tree logon error.
The most common cause of this run-time error is the FairCom Database Engine is not running on your machine. The most likely cause is that the c-tree evaluation license times out after 3 hours and shuts down the server. The solution is to restart the server. See Starting the FairCom Database Engine.
Building and running the tutorials by hand:
If you want to build the tutorials manually, run these commands from the drivers\java.nav\tutorials directory:
javac -cp ../ctreeJTDB.jar JTDB_Tutorial1.java
javac -cp ../ctreeJTDB.jar JTDB_Tutorial2.java
javac -cp ../ctreeJTDB.jar JTDB_Tutorial3.java
javac -cp ../ctreeJTDB.jar JTDB_Tutorial4.java
Troubleshooting the manual build:
error: package FairCom.CtreeDb does not exist
error: package FairCom.CtreeDb.Types does not exist
error: cannot find symbol
These errors indicate that the ctreeJTDB.jar file was not found. Either your -cp parameter is wrong, or you are executing the javac command from the wrong directory. The -cp parameter should point to the ctreeJTDB.jar file in the drivers/java.nav folder.
Executing the Tutorials
You can now execute each example as follows:
java -cp .;../ctreeJTDB.jar -Djava.library.path=../ JTDB_Tutorial1
java -cp .;../ctreeJTDB.jar -Djava.library.path=../ JTDB_Tutorial2
java -cp .;../ctreeJTDB.jar -Djava.library.path=../ JTDB_Tutorial3
java -cp .;../ctreeJTDB.jar -Djava.library.path=../ JTDB_Tutorial4
Note that execution under Linux uses a colon (‘:’) as the classpath (-cp) separator, instead of a semicolon (‘;’).
Also note the classpath (-cp parameter) and java.library.path (-D parameter) tells the JRE where to find the JAR and the shared library files. If you move your project to a new location, you will need to either update those paths or move those files.
Troubleshooting the manual execution / run:
ERROR: [133] - c-tree logon error.
The most common cause of this run-time error is the FairCom Database Engine is not running on your machine. The most likely cause is that the c-tree evaluation license times out after 3 hours and shuts down the server. The solution is to restart the server. See Starting the FairCom Database Engine.
Error: Could not find or load main class JTDB_Tutorial1
The most common cause of this runtime error is leaving the current directory "." out of the classpath (specified by the -cp parameter).
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: FairCom/CtreeDb/CTException
This error indicates that the ctreeJTDB.jar file was not found. Either your -cp parameter is wrong, or you are doing this from the wrong directory. The -cp parameter should point to the ctreeJTDB.jar file in the drivers/java.nav folder.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no mtclijni____ in java.library.path
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libmtclijni____ in java.library.path
This error indicates that the mtclijni shared library / DLL file was not found. Please make sure the folder indicated by your -D parameter contains the mtclijni__.dll (Windows) / libmtclijni__.so (Linux/Unix) / libmtclijni__.dylib (MacOS) file.
Usage: java [-options] class [args...]
-bash: ../ctreeJTDB.jar: Permission denied
This is generally caused (on Linux/Unix) by using a semicolon instead of a colon in the list of folders that follows the -cp parameter.