Name: joT67522 Date: 11/18/97
In a C program, I am using the following code:
/* Create and load a JVM */
jint create_jvm (JavaVM **p_vm, JNIEnv **p_env, JDK1_1InitArgs *vm_args, char *class_path) {
jint err;
vm_args->classpath = class_path;
err = JNI_CreateJavaVM (p_vm, p_env, vm_args);
return (err);
}
/* Destroy a JVM */
jint destroy_jvm (JavaVM **jvm) {
jint err;
err = (**jvm)->DestroyJavaVM (*jvm);
return (err);
}
The creation procedure work well. I can then create instances of classes and manipulate them.
But the destroy_jvm returns always -1.
If this can help, I am using JDK 1.1.4 on win 95.
Needless to add that it is quite urgent for me to fix this problem. So I would really appreciate a fast but complete answer.
Thank you for your answer
-------------------------------------Also from a duplicate entry------------------------
jint destroy_jvm (JavaVM **jvm) {
jint err;
err = (**jvm)->DestroyJavaVM (*jvm);
return (err);
}
It always returns -1. Do I use the function 'DestroyJavaVM' in a bad way?
This procedure is called with a JavaVM created successfully before and with which I an able to create
and manipulate instances of the following class.
class test_java {
test_java () {
System.out.println ("Constructor called");
str_attr = "Hello from Java";
int_attr = 43;
me = this;
static_byte = 1;
attr_class = new attr_class_test ();
}
public test_java me;
public attr_class_test attr_class;
public String str_attr;
public void set_str_attr (String str) {
str_attr = str;
}
// static field
public static byte static_byte;
// <type> routines
public int int_routine () {
System.out.println ("Called int_routine");
return (42);
}
public short short_routine () {
System.out.println ("Called short_routine");
return (43);
}
public char char_routine () {
System.out.println ("Called char_routine");
return 'f';
}
public boolean boolean_routine () {
System.out.println ("Called boolean_routine");
return false;
}
public void void_routine () {
System.out.println ("Called void_routine baby");
}
public float float_routine () {
float f = (float)42.01;
System.out.println ("Called float_routine");
return f;
}
public double double_routine () {
double d = 4.200001;
System.out.println ("Called double routine = " + d );
return d;
}
public double double_pass_routine (double d) {
System.out.println("Called passer = " + d);
return d;
}
public static char multi_arg_routine (double d, int i, String s, short t, char c) {
System.out.println("a double = " + d + "\nan int " + i + "\na String" + s +
"\na short " + t + "\na char " + c + "\n That was fun...");
return '?';
}
public static void print_array (char[] c) {
int finish = c.length;
System.out.println("In pary");
for (int i = 0; i < finish; i++)
System.out.print(c[i] +", ");
System.out.println (";");
}
// end of <temp> routine stuff
public int int_attr;
public void set_int_attr (int newint) {
int_attr = newint;
}
public void one_arg (String s) {
System.out.println ("Received argument: " + s);
}
public void junk () {
String s = "andcedef";
System.out.println ("junk: String is: " + s);
}
public static void root () {
System.out.println ("root routine called");
test_java t = new test_java ();
t.junk ();
}
public static void main (String argv[]) {
System.out.println ("Started from command line");
root ();
}
}
The sooner I receive your answer, the better!
Best Regards
Guillaume Wong-So
(Review ID: 20363)
======================================================================