Urgent!! PB write a program in C/C++ who start a JVM and invoke a method ja
I try to write a program in C/C++ who start a JVM and invoke a method java.
my program run fine if in my essai method, i do't call the JNI method ierror().
but when i call the ierror() there's a bug :
enter in essai
Exception in thread "Thread-0" java.lang.AbstractMethodError
at prog.Prog.client(Prog.java:12)
what's wrong?
Thanks for your help.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Prog.java
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package prog;
import testnative.jAppEngine;
public class Prog extends jAppEngine
{
public void main (String[] args)
{
}
public void essai();
{
System.out.println("enter in essai");
ierror();
System.out.println("quit essai");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// jAppEngine.java
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class jAppEngine
{
public native void ierror();
static
{
System.loadLibrary("jEngine");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// jEngine.cpp (my jEngine.dll)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* Class:testnative_jAppEngine
* Method:ierror
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_testnative_jAppEngine_ierror
(JNIEnv *env, jobject jobj) )
{
ierror( "Dans jAppEngine.ierror");
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Application.cpp
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
JavaVM *vm = 0;
int startJVM( )
{
char *s = 0;
int ret;
jboolean jvmspecified = JNI_FALSE;/* Assume no option specified. */
char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN];
int i, knownVMsCount;
...
...
...
...
...
...
/* If we got here, jvmpath has been correctly initialized. */
ifn.CreateJavaVM = 0;
ifn.GetDefaultJavaVMInitArgs = 0;
if (!LoadJavaVM(jvmpath, &ifn))
return 6;
/* Set default CLASSPATH */
if ((s = getenv("CLASSPATH")) == 0)
{
s = ".";
}
SetClassPath(s);
/* Initialize the virtual machine */
if (!InitializeJVM(&vm, &env, &ifn))
fprintf(stderr, "Could not create the Java virtual machine.\n");
ret = 1;
return ret;
}
int LaunchClass( char *classname, char *jentry, void *p )
{
int retval;
jclass mainClass;
jmethodID mainID;
JNIEnv *env;
retval = vm->AttachCurrentThread((void **)&env,NULL);
jcls = LoadClass(env, classname);
/* Get the application's main method */
mainID = env->GetMethodID( mainClass, jentry, "()V");
/* Invoke main method. */
env->CallVoidMethod( mainClass, mainID); //, mainArgs);
if ((*vm).DetachCurrentThread() != 0)
fprintf(stderr, "Could not detach main thread.\n");
return ret;
}
static void th1(void *p)
{
LaunchClass( "prog.Prog", "client", NULL);
_endthread();
}
int main(int argc, char* argv[])
{
startJVM();
Beep(6000,500);
for (int i=0; i<1; i++)
{
_beginthread(&th1,0,&i);
Sleep(500);
}
return 0;
}

