I have a class in c++ called kitten
class kitten
{
public:
void ChangeColor(int newColor);
int GetColor();
}
Now using JNI I want to give my java program the ability to use this class.
I know how to use JNI to give my java program the ability to call C style functions, but this is a member function.
I thought about something like add a C style function called
kitten* CreateNewKitten();
, which will have one line : return new kitten();
And then somehow return this native kitten
object to JAVA and then the JAVA code will call C style function :
ChangeColor(kitten* myKitten, int newColor)
{
myKitten->changeColor(color)
}
To make things clear, my question is : Is it possible to return my native kitten to java code ? how ? is it the right approach.