Btrieve 2
Loading...
Searching...
No Matches
Using Btrieve with Java

Using Btrieve with Java on Ubuntu 20 x64

Documented below is one approach to configuring the Btrieve 2 SDK for the Java programming language. In this example, we will use the OpenJDK package to target an Ubuntu 20 x64 environment. It is assumed that Zen is already installed and running.

  • Install SWIG and OpenJDK if not already installed.
    • Open a terminal window as a non-"root" user.
    • sudo apt install swig
    • sudo apt install default-jdk
  • Install the Btrieve 2 Linux SDK for Zen.
  • Generate, build, and install Btrieve Java
    • Open a terminal window as a non-"root" user.
    • Change directory into the Btrieve 2 SDK directory.
    • Generate Btrieve Java
      • mkdir -p com/actian/btrieve
      • swig -cppext cpp -outcurrentdir -java -package com.actian.btrieve -outdir com/actian/btrieve -c++ -Iinclude swig/btrieveJava.swig
    • Build Btrieve Java
      • g++ -c -fPIC -Iinclude -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux btrieveJava_wrap.cpp
        • Note that the path to Java used above may differ.
      • g++ -shared btrieveJava_wrap.o -o libbtrieveJava.so -L/usr/local/actianzen/lib64 -lbtrieveCpp
    • Install Btrieve Java
      • sudo cp libbtrieveJava.so /usr/local/actianzen/lib64
      • sudo cp -r com /usr/local/actianzen/lib64
    • Build and execute the Btrieve Java sample program.
      • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/actianzen/lib64
      • export CLASSPATH=$CLASSPATH:/usr/local/actianzen/lib64
      • javac -d . samples/btest.java
      • java btest 9
        • You should see the output "record: (9, 81, 3)".
        • You may need to change the permissions of the current directory if you receive the error "Error: BtrieveClient.FileCreate():STATUS_CODE_PERMISSION_ERROR:Permission error".