Article View: borland.public.jbuilder.java.language
Article #17492Re: JNI question, out of context but....
From: Wayne Cole
Date: Wed, 04 Nov 1998 00:00
Date: Wed, 04 Nov 1998 00:00
61 lines
2183 bytes
2183 bytes
In article <714467$9pb4@forums.borland.com>, pmeulm@wirehub.nl says...
>
> Hi,
>
> Does anyone have the invoke.c sample from the Java tutorial working?
> (it builds your own java.exe. I need this to be able to debug my native
> methods
> which are in a Windows DLL)
>
> I keep on getting:
> Can't find class java.lang.NoClassDefFoundError. (Wrong class path?)
> no matter how I set the classpath or initialization struct.
>
> I am using jdk1.2beta4, Visual C++ 6.00, and evaluating Jbuilder2 for our
> company.
>
> Here is my code,
> best regards,
> Peter
> ------------------
> #include <jni.h>
> #include <stdlib.h>
>
> #ifdef _WIN32
> #define PATH_SEPARATOR ';'
> #else /* UNIX */
> #define PATH_SEPARATOR ':'
> #endif
>
> #define USER_CLASSPATH "." /* where Prog.class is */
>
> int main(int argc, char *argv[]) {
>
> JNIEnv *env;
> JavaVM *jvm;
> JavaVMInitArgs vm_args;
> jint res;
> jclass cls;
> jmethodID mid;
> jstring jstr;
> jobjectArray args;
>
> JavaVMOption options[4];
>
> /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond
> */
>
> options[0].optionString = "-Djava.class.path=c:\\Program
> Files\\JBuilder2\\myprojects\\untitled3;.";
> options[1].optionString = "-verbose:class,gc,jni";
> options[2].optionString = "-Djava.library.path=c:\\Program
Under 1.1.6 and C++ Builder 3.0, the biggest problem is remembering to
run setvars in the console session before starting the jvm to execute the
class with the native calls in it. Not doing that will cause exactly
what you are seeing. Look for the discussion of setvars.bat in the
release notes/hints and tips files.
--
wmc
Technical Details
Message-ID:
<MPG.10a96a9a7070e74298968c@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<714467$9pb4@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,5d814ff95bf64833 X-Google-Attributes: gidf74b3,public From: wmcole@ihpweb.com (Wayne Cole) Subject: Re: JNI question, out of context but.... Date: 1998/11/04 Message-ID: <MPG.10a96a9a7070e74298968c@forums.inprise.com> X-Deja-AN: 408238064 References: <714467$9pb4@forums.borland.com> Organization: Infinity Heart Productions Newsgroups: borland.public.jbuilder.java.language