🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.java.programmer
1 messages
1 total messages Started by Juan Pedro Barbancho Manchon Wed, 21 Jan 1998 00:00
JNI someone could help me
#673
Author: Juan Pedro Barbancho Manchon
Date: Wed, 21 Jan 1998 00:00
104 lines
3622 bytes
Dear sir,
I use the JNI sun example, It compile and build a .exe, but no run well.
Additionally, I try use the JRE demo. Need urgent help. Please, thank
in  avance.

The code:


////////////////////INVOKE.C///////////////////
/* * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.

*
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information. *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */
#include <jni.h>
main()
    {
    JNIEnv *env;
    JavaVM *jvm;
    JDK1_1InitArgs vm_args;
    jint res;
    jclass cls;
    jmethodID mid;
    jstring jstr;
    jobjectArray args;
    /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and
beyond */
    vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
    res = JNI_CreateJavaVM(&jvm,&env,&vm_args);
        if (res < 0) {
        fprintf(stderr, "Can't create Java VM\n");
        exit(1);
        }
    cls = (*env)->FindClass(env, "Prog.class");
        if (cls == 0) {
        fprintf(stderr, "Can't find Prog class\n");
        exit(1);
        }
    mid = (*env)->GetStaticMethodID(env, cls, "main",
"([Ljava/lang/String;)V");
    if (mid == 0) {
     fprintf(stderr, "Can't find Prog.main\n");
        exit(1);
        }
    jstr = (*env)->NewStringUTF(env, " from C!");
    if (jstr == 0) {
     fprintf(stderr, "Out of memory\n");
  exit(1);
     }
    args = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env,
"java/lang/String"), jstr);
    if (args == 0) {
     fprintf(stderr, "Out of memory\n");
  exit(1);
     }
    (*env)->CallStaticVoidMethod(env, cls, mid, args);
    (*jvm)->DestroyJavaVM(jvm);
}

The Java program:

//////////////////////////PROG.JAVA////////////////////////////////

public class Prog {
 public static void main(String[] args) {
  System.out.println("Hello World");
 }
}



The error:

can't fing Prog class

The . is in the classpath, Prog.class is in . directory.


Please, send me faster, Thank you

mail: ct2bamaj@uco.es

JuanP
--
--------------------------------------------------
Nombre y apelllidos:
Juan Pedro Barbancho Manch�n
Organizaci�n:
CTI
http://www.uco.es/grupos/cti
E-mail:
ct2bamaj@uco.es
Java Senior Programmer
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads