1

I have written a java program that does some logic check which involves a database call.

I was able to call a simple cpp program from java using JNI stackoverflow question.

How can I do the opposite, i.e Is there a way to call java (with database) from a cpp program?

I have PostgreSQL database. Any direction would be a great starting point for me.

Thank you for your time. :)

Edit

Seems like a similar question has a very nice answer here link

Arka Mallick
  • 1,206
  • 3
  • 15
  • 28

1 Answers1

2

JNI is working from the other way as well cpp -> java http://java.sun.com/javase/6/docs/technotes/guides/jni/index.html

/* load and initialize a Java VM, return a JNI interface  
* pointer in env */ 
JNI_CreateJavaVM(&jvm, &env, &vm_args); 

/* invoke the Main.test method using the JNI */ 
jclass cls = env->FindClass("Main"); 
jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V"); 
env->CallStaticVoidMethod(cls, mid, 100);