Unable to compile Rocksdb java in ubuntu with fatal error of no jni.h file found

445 views Asked by At

I am trying to compile rocksdb java API to put into my java project. But I am unable to compile it.

I clone the rocksdb git hub repository (https://github.com/facebook/rocksdb.git)

And ran the command:

make rocksdbjava

However, during the compilation, there are fatal errors of no jni.h file/ directory found, and the compilation terminated:

Generating target/apidocs/org/rocksdb/WriteBatch.SavePoint.html...
Generating target/apidocs/org/rocksdb/WriteBatchInterface.html...
Generating target/apidocs/org/rocksdb/WriteBatchWithIndex.html...
Generating target/apidocs/org/rocksdb/WriteBufferManager.html...
Generating target/apidocs/org/rocksdb/WriteOptions.html...
Generating target/apidocs/org/rocksdb/util/ByteUtil.html...
Generating target/apidocs/org/rocksdb/util/BytewiseComparator.html...
Generating target/apidocs/org/rocksdb/util/Environment.html...
Generating target/apidocs/org/rocksdb/util/IntComparator.html...
Generating target/apidocs/org/rocksdb/util/ReverseBytewiseComparator.html...
Generating target/apidocs/org/rocksdb/util/SizeUnit.html...
Generating target/apidocs/org/rocksdb/package-summary.html...
Generating target/apidocs/org/rocksdb/package-tree.html...
Generating target/apidocs/org/rocksdb/util/package-summary.html...
Generating target/apidocs/org/rocksdb/util/package-tree.html...
Generating target/apidocs/constant-values.html...
Generating target/apidocs/serialized-form.html...
Building index for all the packages and classes...
Generating target/apidocs/overview-tree.html...
Generating target/apidocs/index-all.html...
Building index for all classes...
Generating target/apidocs/allclasses-index.html...
Generating target/apidocs/allpackages-index.html...
Generating target/apidocs/deprecated-list.html...
Building index for all classes...
Generating target/apidocs/allclasses.html...
Generating target/apidocs/allclasses.html...
Generating target/apidocs/index.html...
Generating target/apidocs/overview-summary.html...
Generating target/apidocs/help-doc.html...
make[1]: Leaving directory '/home/osboxes/rocksdb/rocksdb/java'
java/rocksjni/backupenginejni.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/backupablejni.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/checkpoint.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/clock_cache.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/columnfamilyhandle.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compact_range_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_filter.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_filter_factory.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/compaction_filter_factory_jnicallback.cc:9:
./java/./rocksjni/compaction_filter_factory_jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_job_info.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_job_stats.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_options_fifo.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compaction_options_universal.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/comparator.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/comparatorjnicallback.cc:9:
./java/./rocksjni/comparatorjnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/compression_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/concurrent_task_limiter.cc:3:10: fatal error: jni.h: No such file or directory
    3 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/config_options.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/env.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/env_options.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/ingest_external_file_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/filter.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/iterator.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/jnicallback.cc:10:
./java/./rocksjni/jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/loggerjnicallback.cc:9:
./java/./include/org_rocksdb_Logger.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/lru_cache.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/memtablejni.cc:8:
./java/./include/org_rocksdb_HashLinkedListMemTableConfig.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/memory_util.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/merge_operator.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/native_comparator_wrapper_test.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/optimistic_transaction_db.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/optimistic_transaction_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/options.cc:11:10: fatal error: jni.h: No such file or directory
   11 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/options_util.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/persistent_cache.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/ratelimiterjni.cc:8:
./java/./include/org_rocksdb_RateLimiter.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/remove_emptyvalue_compactionfilterjni.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/cassandra_compactionfilterjni.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/cassandra_value_operator.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/restorejni.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/rocks_callback_object.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/rocksjni.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/rocksdb_exception_test.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/slice.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/snapshot.cc:8:10: fatal error: jni.h: No such file or directory
    8 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/sst_file_manager.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/sst_file_writerjni.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/sst_file_readerjni.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/sst_file_reader_iterator.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/sst_partitioner.cc:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/statistics.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/table.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/table_filter.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/table_filter_jnicallback.cc:9:
./java/./rocksjni/table_filter_jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/thread_status.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/trace_writer.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/trace_writer_jnicallback.cc:9:
./java/./rocksjni/trace_writer_jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction_db.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction_db_options.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction_log.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/transaction_notifier.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/transaction_notifier_jnicallback.cc:9:
./java/./rocksjni/transaction_notifier_jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/ttl.cc:10:10: fatal error: jni.h: No such file or directory
   10 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/wal_filter.cc:9:10: fatal error: jni.h: No such file or directory
    9 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/wal_filter_jnicallback.cc:9:
./java/./rocksjni/wal_filter_jnicallback.h:12:10: fatal error: jni.h: No such file or directory
   12 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/write_batch.cc:12:
./java/./include/org_rocksdb_WriteBatch.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/writebatchhandlerjnicallback.cc:9:
./java/./rocksjni/writebatchhandlerjnicallback.h:13:10: fatal error: jni.h: No such file or directory
   13 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/write_batch_test.cc:12:
./java/./include/org_rocksdb_WriteBatch.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
In file included from java/rocksjni/write_batch_with_index.cc:10:
./java/./include/org_rocksdb_WBWIRocksIterator.h:2:10: fatal error: jni.h: No such file or directory
    2 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
java/rocksjni/write_buffer_manager.cc:6:10: fatal error: jni.h: No such file or directory
    6 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
make: *** [Makefile:2245: rocksdbjava] Error 1

Using the locate command, I am able to find jni.h file:

/home/osboxes/rocksdb/rocksdb/java/rocksjni/statisticsjni.h
/usr/lib/jvm/java-11-openjdk-amd64/include/jni.h

Any ideas how to fix this problem?

1

There are 1 answers

0
Jay Zhuang On

You need to set environment variable JAVA_HOME to your JDK. In your example, it should be:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64