The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001

Advertisement

Advertisement
where you can ask and answer Java programming questions.">
artima.com - a resource for Java and Jini developers
Artima | Search | Java | Design | JVM | Jini | Books | Seminars | Subscribe 


Java Answers Forum
September 2001

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

JNI loading an executable

Posted by bjoern on September 14, 2001 at 4:54 AM

i wrote a c++ prog, that invokes the jvm. than i started a java class.methode which is a native methode. (before i loaded the exe, which invokes the vm into the vm, so the funktion-name-mapping can work)

c++ code
{
...; jvm->load();...
jniEnv->CallStaticMethod(..go_IDs..);
}
extern "C"
{
void Java_ClassName_funktionName(JNIEnv*,jclass)
{
printf("in the native code");
}
}

/////////////////
java-code

static native void funktionName();

static void go()
{
System.load("PathToEXE");
funktionName();
}

/////////////////////////////////

thats all
it works fine if i make the invoking from c++.
if i try to start the methode go() from the java-main() the call
to the native methode works fine, but the printf() is not executed. the java-vm exit with code 128. it dont even throws an exception. and i dont know what's the problem. if i dont printf, but return it also works, i can also call other funktions-methods from the exe, but not anything else.
is it impossible to link an *.exe to the vm? are the other dependent dlls (for printf()) not loaded, who can help




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us