🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8415

JNI

#8415
From: Hosni
Date: Tue, 20 Mar 2001 15:02
71 lines
2652 bytes
hi all,
I have the following code:
---------------------------
#include "jni.h"
//#include "jni_md.h"
//#include "HelloWorld.h"

void main(int argc, char *argv[], char **envp) {
  JavaVMOption options[2];
  JavaVMInitArgs vm_args;
  JavaVM *jvm = (JavaVM *)0;
  JNIEnv *env ;
  long result;
  jmethodID mid;
  jfieldID fid;
  jobject jobj;
  jclass cls;
  int i, asize;
  JavaVMAttachArgs args;

  options[0].optionString = "-Djava.class.path=.";
  options[1].optionString = "-Djava.compiler=NONE";


  vm_args.version = JNI_VERSION_1_2;

  vm_args.options = options;
  vm_args.nOptions = 2;
  vm_args.ignoreUnrecognized = JNI_FALSE;
  args.version=JNI_VERSION_1_2;
  args.name ="user";
  args.group =NULL;

  result = JNI_CreateJavaVM(
             &jvm,(void **)&env, &vm_args);
/*
  if(result == JNI_ERR ) {
    printf("Error invoking the JVM");
    exit (-1);
  }
*/
  cls = (*env)->FindClass(env,"Helloworld");
  if( cls == NULL ) {
    printf("can't find class HelloWorld\n");
    exit (-1);
  }
  (*env)->ExceptionClear(env);
  mid=(*env)->GetMethodID(env, cls, "writeHello", "()V");
  jobj=(*env)->NewObject(env, cls, mid);
 
  (*env)->CallVoidMethod(env,jobj,mid);
 
  (*jvm)->DestroyJavaVM(jvm);
  
}

---------------------------
When I try to run it in MS Visual C++6 , when I try to compile this I get the message:
----------------------------
Linking...
   Creating library Debug/HelloWorldImp.lib and object Debug/HelloWorldImp.exp
CallToJava.obj : error LNK2001: unresolved external symbol __imp__JNI_CreateJavaVM@12
Debug/HelloWorldImp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

HelloWorldImp.exe - 2 error(s), 4 warning(s)
--------------------------------
Can u please help me ASAP, Thanks.

Note: I have copied the file jni.h to the current wroking folder.
Technical Details
Message-ID: <3ab770f6$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!207.105.83.65

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,215f47727150c3f2,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-23 03:48:07 PST
From: "Hosni" <h.saqallah@eskadenia.com>
Sender: "Hosni" <h.saqallah@eskadenia.com>
Reply-To: "Hosni" <h.saqallah@eskadenia.com>
Subject: JNI
Newsgroups: borland.public.jbuilder.java.language
X-User-Info: 212.118.3.114 212.118.3.114    
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3ab770f6$1_2@dnews>
Date: 20 Mar 2001 07:02:14 -0800
X-Trace: 20 Mar 2001 07:02:14 -0800, 207.105.83.65
Lines: 71
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!207.105.83.65