1

I am trying to generate C header file for JNI (Linux). I read documentation and questions on javah, but I still get the same error

Error: Could not find class file for 'org.sqlite.core.NativeDB'

I think I have very obvious mistake but I really don't see any... So, I need to generate header file from the NativeDB.class and the path is:

/u/users/maas/user123/sqlite/sqlite-jdbc-3.21.0/target/common-lib/org/sqlite/core/NativeDB.class

I go to the common-lib folder and call javah from the path of:

/u/users/maas/user123/sqlite/sqlite-jdbc-3.21.0/target/common-lib/

The commands I tried:

javah -classpath "/u/users/maas/user123/sqlite/sqlite-jdbc-3.21.0/target/common-lib/org/sqlite/core" org.sqlite.core.NativeDB
javah org.sqlite.core.NativeDB

The error I get:

Error: Could not find class file for 'org.sqlite.core.NativeDB'

I see the NativeDB.class file in the correct directory I mentioned. In the NativeDB.java (which is not in the same folder with NativeDB.class IF it is important) there is a package path:

package org.sqlite.core;
Roman
  • 33
  • 7
  • 1
    Try shortening your classpath to `/u/users/maas/user123/sqlite/sqlite-jdbc-3.21.0/target/common-lib`. The intermediate directories are part of the class lookup. – Botje Jul 26 '21 at 15:51
  • @Botje thank you for the reply. I tried your suggestion but it gives the same error :( – Roman Jul 26 '21 at 16:36
  • I downloaded [the jar from maven repository](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc/3.21.0.1), unpacked it, and `javah -cp . org.sqlite.core.NativeDB` Just Worked(tm). Not sure what else I can say. – Botje Jul 27 '21 at 11:30
  • 1
    Did you copy the command line from some documentation? Your quotes look like typographic quotation marks (Unicode 201D) instead of "normal" quotes (Unicode 0022). This way the classpath won't be recognized at all – user2543253 Jul 28 '21 at 09:53

1 Answers1

1

I found the issue (that was really obvious and dumb).

Commands I wrote in the question are correct. I am using USS (UNIX System Services) for Z/OS and ftp for transferring files. I didn't check that I sent .class files via ftp NOT in binary format. And for this reason Java couldn't find the classes because of wrong encoding.

All you need is just turn on the binary mode in the ftp like so:

ftp server.name.com
..login...
bi
mput *class

The bi command enables binary mode. The .class files are expected to be in this format.

Roman
  • 33
  • 7