I am trying to write a wrapper for a dynamic library that I do not have all of the source code for, just as most people who use JNI seem to be trying to do.
What I need to do is call the constructor of a C++ class with a Java wrapper class and then use that C++ class instance for all further native methods through the Java class's instance. This works fine as long as there is only ever one instance of the Java class, as soon as a new instance is made the old C++ instance is overwritten with a new one. I must be able to create multiple instances as each instance handles a single sensor.
Is there any way to elegantly tie the Java class instance to the C++ class instance?
Disclaimer:I am not a C++ programmer any more than a monkey is a human. Even the simplest answers on the C++ end might help.