vassim
asked on
JNI exceptions thrown
I have created a java GUI and built a cpp dll file to be called by the GUI, when I build the machine generated .h file (javah) it creates a file that looks unusual but works, I am trying to collect a machine name, username, password and 3 boolean values in the GUI, and pass them as an object to the dll, if I just call the dll and not pass the object then it works fine, however I tried to pass the object and pull out the attributes then I get very unusual exceptions during runtime, I got the technique for extracting the values from this site:
http://www.pacifier.com/~mmead/cs510jip/jni/
Here is the javah generated file:
************************** ********** ********** ********** ********** ***
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class guineyd_java_ProgramStartu p */
#ifndef _Included_guineyd_java_Pro gramStartu p
#define _Included_guineyd_java_Pro gramStartu p
#ifdef __cplusplus
extern "C" {
#endif
#undef guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ UNKNOWN
#define guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ UNKNOWN 0L
#undef guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ DEFAULT
#define guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ DEFAULT 1L
#undef guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ SET
#define guineyd_java_ProgramStartu p_FOCUS_TR AVERSABLE_ SET 2L
/* Inaccessible static: focusTraversalKeyPropertyN ames */
/* Inaccessible static: LOCK */
/* Inaccessible static: dbg */
/* Inaccessible static: isInc */
/* Inaccessible static: incRate */
#undef guineyd_java_ProgramStartu p_TOP_ALIG NMENT
#define guineyd_java_ProgramStartu p_TOP_ALIG NMENT 0.0f
#undef guineyd_java_ProgramStartu p_CENTER_A LIGNMENT
#define guineyd_java_ProgramStartu p_CENTER_A LIGNMENT 0.5f
#undef guineyd_java_ProgramStartu p_BOTTOM_A LIGNMENT
#define guineyd_java_ProgramStartu p_BOTTOM_A LIGNMENT 1.0f
#undef guineyd_java_ProgramStartu p_LEFT_ALI GNMENT
#define guineyd_java_ProgramStartu p_LEFT_ALI GNMENT 0.0f
#undef guineyd_java_ProgramStartu p_RIGHT_AL IGNMENT
#define guineyd_java_ProgramStartu p_RIGHT_AL IGNMENT 1.0f
#undef guineyd_java_ProgramStartu p_serialVe rsionUID
#define guineyd_java_ProgramStartu p_serialVe rsionUID -7644114512714619750i64
/* Inaccessible static: metrics */
/* Inaccessible static: class_00024java_00024awt_0 0024Compon ent */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Compo nentListen er */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Focus Listener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Hiera rchyListen er */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Hiera rchyBounds Listener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024KeyLi stener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Mouse Listener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Mouse MotionList ener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Mouse WheelListe ner */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Input MethodList ener */
/* Inaccessible static: class_00024java_00024beans _00024Prop ertyChange Listener */
#undef guineyd_java_ProgramStartu p_serialVe rsionUID
#define guineyd_java_ProgramStartu p_serialVe rsionUID 4613797578919906343i64
/* Inaccessible static: dbg */
#undef guineyd_java_ProgramStartu p_INCLUDE_ SELF
#define guineyd_java_ProgramStartu p_INCLUDE_ SELF 1L
#undef guineyd_java_ProgramStartu p_SEARCH_H EAVYWEIGHT S
#define guineyd_java_ProgramStartu p_SEARCH_H EAVYWEIGHT S 1L
/* Inaccessible static: class_00024java_00024awt_0 0024Contai ner */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Conta inerListen er */
/* Inaccessible static: class_00024java_00024awt_0 0024Keyboa rdFocusMan ager */
/* Inaccessible static: systemSyncLWRequests */
#undef guineyd_java_ProgramStartu p_OPENED
#define guineyd_java_ProgramStartu p_OPENED 1L
/* Inaccessible static: nameCounter */
#undef guineyd_java_ProgramStartu p_serialVe rsionUID
#define guineyd_java_ProgramStartu p_serialVe rsionUID 4497834738069338734i64
/* Inaccessible static: dbg */
/* Inaccessible static: class_00024java_00024awt_0 0024Window */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Windo wListener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Windo wFocusList ener */
/* Inaccessible static: class_00024java_00024awt_0 0024event_ 00024Windo wStateList ener */
#undef guineyd_java_ProgramStartu p_DEFAULT_ CURSOR
#define guineyd_java_ProgramStartu p_DEFAULT_ CURSOR 0L
#undef guineyd_java_ProgramStartu p_CROSSHAI R_CURSOR
#define guineyd_java_ProgramStartu p_CROSSHAI R_CURSOR 1L
#undef guineyd_java_ProgramStartu p_TEXT_CUR SOR
#define guineyd_java_ProgramStartu p_TEXT_CUR SOR 2L
#undef guineyd_java_ProgramStartu p_WAIT_CUR SOR
#define guineyd_java_ProgramStartu p_WAIT_CUR SOR 3L
#undef guineyd_java_ProgramStartu p_SW_RESIZ E_CURSOR
#define guineyd_java_ProgramStartu p_SW_RESIZ E_CURSOR 4L
#undef guineyd_java_ProgramStartu p_SE_RESIZ E_CURSOR
#define guineyd_java_ProgramStartu p_SE_RESIZ E_CURSOR 5L
#undef guineyd_java_ProgramStartu p_NW_RESIZ E_CURSOR
#define guineyd_java_ProgramStartu p_NW_RESIZ E_CURSOR 6L
#undef guineyd_java_ProgramStartu p_NE_RESIZ E_CURSOR
#define guineyd_java_ProgramStartu p_NE_RESIZ E_CURSOR 7L
#undef guineyd_java_ProgramStartu p_N_RESIZE _CURSOR
#define guineyd_java_ProgramStartu p_N_RESIZE _CURSOR 8L
#undef guineyd_java_ProgramStartu p_S_RESIZE _CURSOR
#define guineyd_java_ProgramStartu p_S_RESIZE _CURSOR 9L
#undef guineyd_java_ProgramStartu p_W_RESIZE _CURSOR
#define guineyd_java_ProgramStartu p_W_RESIZE _CURSOR 10L
#undef guineyd_java_ProgramStartu p_E_RESIZE _CURSOR
#define guineyd_java_ProgramStartu p_E_RESIZE _CURSOR 11L
#undef guineyd_java_ProgramStartu p_HAND_CUR SOR
#define guineyd_java_ProgramStartu p_HAND_CUR SOR 12L
#undef guineyd_java_ProgramStartu p_MOVE_CUR SOR
#define guineyd_java_ProgramStartu p_MOVE_CUR SOR 13L
#undef guineyd_java_ProgramStartu p_NORMAL
#define guineyd_java_ProgramStartu p_NORMAL 0L
#undef guineyd_java_ProgramStartu p_ICONIFIE D
#define guineyd_java_ProgramStartu p_ICONIFIE D 1L
#undef guineyd_java_ProgramStartu p_MAXIMIZE D_HORIZ
#define guineyd_java_ProgramStartu p_MAXIMIZE D_HORIZ 2L
#undef guineyd_java_ProgramStartu p_MAXIMIZE D_VERT
#define guineyd_java_ProgramStartu p_MAXIMIZE D_VERT 4L
#undef guineyd_java_ProgramStartu p_MAXIMIZE D_BOTH
#define guineyd_java_ProgramStartu p_MAXIMIZE D_BOTH 6L
/* Inaccessible static: nameCounter */
#undef guineyd_java_ProgramStartu p_serialVe rsionUID
#define guineyd_java_ProgramStartu p_serialVe rsionUID 2673458971256075116i64
/* Inaccessible static: class_00024java_00024awt_0 0024Frame */
#undef guineyd_java_ProgramStartu p_EXIT_ON_ CLOSE
#define guineyd_java_ProgramStartu p_EXIT_ON_ CLOSE 3L
/* Inaccessible static: defaultLookAndFeelDecorate dKey */
/*
 * Class:   guineyd_java_ProgramStartu p
 * Method:   driver
 * Signature: (Lguineyd/java/ProgramStar tup$Machin eDetails;) V
 */
JNIEXPORT void JNICALL Java_guineyd_java_ProgramS tartup_dri ver
 (JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif
************************** ********** ********** ********** ********** *
I dont know what all the #defines are for, these dont usually appear in the examples on the net.
at the very end of the file above you will see the definition for the native method, which looks OK(appart from all the stuff above it).
Here is the cpp code for reading the object and its attributes, if I get rid of all the code inside the bracket and just run a cpp program like it was a .exe then it works fine.
************************** ********** ********** ********** ********** **
JNIEXPORT void JNICALL Java_guineyd_java_ProgramS tartup_dri ver
 (JNIEnv * env, jobject obj, jobject jclazz)
{
static jclass javaMcClass = env->GetObjectClass(jclazz );
static jmethodID mid = env->GetMethodID(javaMcCla ss, "MachineDetails", "");
static jfieldID fidMcName = env->GetFieldID
      (javaMcClass, "BSTRMachineName", "Ljava/lang/String;");
static jstring javaMcName = (jstring) env->GetObjectField(obj, fidMcName);
static jfieldID fidUName = env->GetFieldID
      (javaMcClass, "UserName", "Ljava/lang/String;");
static jstring javaUserName = (jstring) env->GetObjectField(obj, fidUName);
static jfieldID fidPWord = env->GetFieldID
      (javaMcClass, "PassWd", "Ljava/lang/String;");
static jstring javaPassWd = (jstring) env->GetObjectField(obj, fidPWord);
static jfieldID fidAvailMem = env->GetFieldID
      (javaMcClass, "AvailMemory", "Z");
static jboolean javaAvailMemory = (bool) env->GetObjectField(obj, fidAvailMem);
static jfieldID fidDiskSpace = env->GetFieldID
      (javaMcClass, "DiskSpaceFree", "Z");
static jboolean javaDiskSpaceFree = (bool) env->GetObjectField(obj, fidDiskSpace);
static jfieldID fidLoadPerc = env->GetFieldID
      (javaMcClass, "LoadPercentage", "Z");
static jboolean javaLoadPercentage = (bool) env->GetObjectField(obj, fidLoadPerc); Â
************************** ********** ********** ********** **********
and here is what I get when I run the whole app.
I start the java GUI and the JNI is initiated by a buttons event listener,
************************** ********** ********** ********** **********
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x208
7FCAC
Function=[Unknown.]
Library=C:\COLLEGE\attempt \cpp\guine yd\guineyd .dll
NOTE: We are unable to locate the function name symbol for the error
   just occurred. Please refer to release documentation for possible
   reason and solutions.
Current Java thread:
    at guineyd.java.ProgramStartu p.driver(N ative Method)
    at guineyd.java.ProgramStartu p.Login(Pr ogramStart up.java:19 5)
    at guineyd.java.ProgramStartu p$Window_a ctionAdapt er.actionP erformed(P rog
ramStartup.java:158)
    at javax.swing.AbstractButton .fireActio nPerformed (AbstractB utton.java :17
86)
    at javax.swing.AbstractButton $ForwardAc tionEvents .actionPer formed(Abs tra
ctButton.java:1839)
    at javax.swing.DefaultButtonM odel.fireA ctionPerfo rmed(Defau ltButtonMo del
.java:420)
    at javax.swing.DefaultButtonM odel.setPr essed(Defa ultButtonM odel.java: 258
)
    at javax.swing.plaf.basic.Bas icButtonLi stener.mou seReleased (BasicButt onL
istener.java:245)
    at java.awt.Component.process MouseEvent (Component .java:5100 )
    at java.awt.Component.process Event(Comp onent.java :4897)
    at java.awt.Container.process Event(Cont ainer.java :1569)
    at java.awt.Component.dispatc hEventImpl (Component .java:3615 )
    at java.awt.Container.dispatc hEventImpl (Container .java:1627 )
    at java.awt.Component.dispatc hEvent(Com ponent.jav a:3477)
    at java.awt.LightweightDispat cher.retar getMouseEv ent(Contai ner.java:3 483
)
    at java.awt.LightweightDispat cher.proce ssMouseEve nt(Contain er.java:31 98)
    at java.awt.LightweightDispat cher.dispa tchEvent(C ontainer.j ava:3128)
    at java.awt.Container.dispatc hEventImpl (Container .java:1613 )
    at java.awt.Window.dispatchEv entImpl(Wi ndow.java: 1606)
    at java.awt.Component.dispatc hEvent(Com ponent.jav a:3477)
    at java.awt.EventQueue.dispat chEvent(Ev entQueue.j ava:456)
    at java.awt.EventDispatchThre ad.pumpOne EventForHi erarchy(Ev entDispatc hTh
read.java:201)
    at java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Even tDispatchT hre
ad.java:151)
    at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 45)
    at java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 37)
    at java.awt.EventDispatchThre ad.run(Eve ntDispatch Thread.jav a:100)
Dynamic libraries:
0x00400000 - 0x00406000 Â Â Â Â C:\JBuilderX\jdk1.4\bin\ja va.exe
0x77F80000 - 0x77FFD000 Â Â Â Â C:\WINNT\system32\ntdll.dl l
0x7C2D0000 - 0x7C332000 Â Â Â Â C:\WINNT\system32\ADVAPI32 .dll
0x7C570000 - 0x7C628000 Â Â Â Â C:\WINNT\system32\KERNEL32 .DLL
0x77D30000 - 0x77DA1000 Â Â Â Â C:\WINNT\system32\RPCRT4.D LL
0x78000000 - 0x78045000 Â Â Â Â C:\WINNT\system32\MSVCRT.d ll
0x08000000 - 0x08136000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\client\j vm.dll
0x77E10000 - 0x77E75000 Â Â Â Â C:\WINNT\system32\USER32.d ll
0x77F40000 - 0x77F7E000 Â Â Â Â C:\WINNT\system32\GDI32.DL L
0x77570000 - 0x775A0000 Â Â Â Â C:\WINNT\system32\WINMM.dl l
0x10000000 - 0x10007000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\hpi.dll
0x007C0000 - 0x007CE000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\verify.d ll
0x007D0000 - 0x007E8000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\java.dll
0x007F0000 - 0x007FD000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\zip.dll
0x18270000 - 0x1837F000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\awt.dll
0x77800000 - 0x7781E000 Â Â Â Â C:\WINNT\system32\WINSPOOL .DRV
0x76620000 - 0x76630000 Â Â Â Â C:\WINNT\system32\MPR.DLL
0x75E60000 - 0x75E7A000 Â Â Â Â C:\WINNT\system32\IMM32.dl l
0x77A50000 - 0x77B3F000 Â Â Â Â C:\WINNT\system32\ole32.dl l
0x18380000 - 0x183D0000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi n\fontmana ger.dll
0x51000000 - 0x5104B000 Â Â Â Â C:\WINNT\system32\ddraw.dl l
0x728A0000 - 0x728A6000 Â Â Â Â C:\WINNT\system32\DCIMAN32 .dll
0x5C000000 - 0x5C0C7000 Â Â Â Â C:\WINNT\system32\D3DIM700 .DLL
0x20860000 - 0x20890000 Â Â Â Â C:\COLLEGE\attempt\cpp\gui neyd\guine yd.dll
0x779B0000 - 0x77A4B000 Â Â Â Â C:\WINNT\system32\OLEAUT32 .dll
0x20890000 - 0x2094C000 Â Â Â Â C:\WINNT\system32\MSVCP71D .dll
0x20950000 - 0x209D7000 Â Â Â Â C:\WINNT\system32\MSVCR71D .dll
0x775A0000 - 0x77630000 Â Â Â Â C:\WINNT\system32\CLBCATQ. DLL
0x65A60000 - 0x65A6A000 Â Â Â Â C:\WINNT\System32\wbem\wbe mprox.dll
0x65C20000 - 0x65CCD000 Â Â Â Â C:\WINNT\System32\wbem\wbe mcomn.dll
0x77920000 - 0x77943000 Â Â Â Â C:\WINNT\system32\imagehlp .dll
0x72A00000 - 0x72A2D000 Â Â Â Â C:\WINNT\system32\DBGHELP. dll
0x690A0000 - 0x690AB000 Â Â Â Â C:\WINNT\system32\PSAPI.DL L
Heap at VM Abort:
Heap
 def new generation  total 576K, used 543K [0x10010000, 0x100b0000, 0x104f0000)
 eden space 512K,  93% used [0x10010000, 0x10087fa0, 0x10090000)
 from space 64K, 100% used [0x100a0000, 0x100b0000, 0x100b0000)
 to  space 64K,  0% used [0x10090000, 0x10090000, 0x100a0000)
 tenured generation  total 1408K, used 129K [0x104f0000, 0x10650000, 0x14010000
)
  the space 1408K,  9% used [0x104f0000, 0x10510740, 0x10510800, 0x10650000)
 compacting perm gen  total 4352K, used 4224K [0x14010000, 0x14450000, 0x1801000
0)
  the space 4352K,  97% used [0x14010000, 0x14430200, 0x14430200, 0x14450000)
Local Time = Sat May 01 18:38:55 2004
Elapsed Time = 5
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_01-b06 mixed mode)
#
# An error report file has been saved as hs_err_pid2492.log.
# Please refer to the file for further information.
#
Press any key to continue . . .
************************** ********** ********** ********** ********** **
Any help is realy apreciated
http://www.pacifier.com/~mmead/cs510jip/jni/
Here is the javah generated file:
**************************
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class guineyd_java_ProgramStartu
#ifndef _Included_guineyd_java_Pro
#define _Included_guineyd_java_Pro
#ifdef __cplusplus
extern "C" {
#endif
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: focusTraversalKeyPropertyN
/* Inaccessible static: LOCK */
/* Inaccessible static: dbg */
/* Inaccessible static: isInc */
/* Inaccessible static: incRate */
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: metrics */
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024beans
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: dbg */
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: systemSyncLWRequests */
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: nameCounter */
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: dbg */
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
/* Inaccessible static: class_00024java_00024awt_0
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: nameCounter */
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: class_00024java_00024awt_0
#undef guineyd_java_ProgramStartu
#define guineyd_java_ProgramStartu
/* Inaccessible static: defaultLookAndFeelDecorate
/*
 * Class:   guineyd_java_ProgramStartu
 * Method:   driver
 * Signature: (Lguineyd/java/ProgramStar
 */
JNIEXPORT void JNICALL Java_guineyd_java_ProgramS
 (JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif
**************************
I dont know what all the #defines are for, these dont usually appear in the examples on the net.
at the very end of the file above you will see the definition for the native method, which looks OK(appart from all the stuff above it).
Here is the cpp code for reading the object and its attributes, if I get rid of all the code inside the bracket and just run a cpp program like it was a .exe then it works fine.
**************************
JNIEXPORT void JNICALL Java_guineyd_java_ProgramS
 (JNIEnv * env, jobject obj, jobject jclazz)
{
static jclass javaMcClass = env->GetObjectClass(jclazz
static jmethodID mid = env->GetMethodID(javaMcCla
static jfieldID fidMcName = env->GetFieldID
      (javaMcClass, "BSTRMachineName", "Ljava/lang/String;");
static jstring javaMcName = (jstring) env->GetObjectField(obj, fidMcName);
static jfieldID fidUName = env->GetFieldID
      (javaMcClass, "UserName", "Ljava/lang/String;");
static jstring javaUserName = (jstring) env->GetObjectField(obj, fidUName);
static jfieldID fidPWord = env->GetFieldID
      (javaMcClass, "PassWd", "Ljava/lang/String;");
static jstring javaPassWd = (jstring) env->GetObjectField(obj, fidPWord);
static jfieldID fidAvailMem = env->GetFieldID
      (javaMcClass, "AvailMemory", "Z");
static jboolean javaAvailMemory = (bool) env->GetObjectField(obj, fidAvailMem);
static jfieldID fidDiskSpace = env->GetFieldID
      (javaMcClass, "DiskSpaceFree", "Z");
static jboolean javaDiskSpaceFree = (bool) env->GetObjectField(obj, fidDiskSpace);
static jfieldID fidLoadPerc = env->GetFieldID
      (javaMcClass, "LoadPercentage", "Z");
static jboolean javaLoadPercentage = (bool) env->GetObjectField(obj, fidLoadPerc); Â
**************************
and here is what I get when I run the whole app.
I start the java GUI and the JNI is initiated by a buttons event listener,
**************************
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION
7FCAC
Function=[Unknown.]
Library=C:\COLLEGE\attempt
NOTE: We are unable to locate the function name symbol for the error
   just occurred. Please refer to release documentation for possible
   reason and solutions.
Current Java thread:
    at guineyd.java.ProgramStartu
    at guineyd.java.ProgramStartu
    at guineyd.java.ProgramStartu
ramStartup.java:158)
    at javax.swing.AbstractButton
86)
    at javax.swing.AbstractButton
ctButton.java:1839)
    at javax.swing.DefaultButtonM
.java:420)
    at javax.swing.DefaultButtonM
)
    at javax.swing.plaf.basic.Bas
istener.java:245)
    at java.awt.Component.process
    at java.awt.Component.process
    at java.awt.Container.process
    at java.awt.Component.dispatc
    at java.awt.Container.dispatc
    at java.awt.Component.dispatc
    at java.awt.LightweightDispat
)
    at java.awt.LightweightDispat
    at java.awt.LightweightDispat
    at java.awt.Container.dispatc
    at java.awt.Window.dispatchEv
    at java.awt.Component.dispatc
    at java.awt.EventQueue.dispat
    at java.awt.EventDispatchThre
read.java:201)
    at java.awt.EventDispatchThre
ad.java:151)
    at java.awt.EventDispatchThre
    at java.awt.EventDispatchThre
    at java.awt.EventDispatchThre
Dynamic libraries:
0x00400000 - 0x00406000 Â Â Â Â C:\JBuilderX\jdk1.4\bin\ja
0x77F80000 - 0x77FFD000 Â Â Â Â C:\WINNT\system32\ntdll.dl
0x7C2D0000 - 0x7C332000 Â Â Â Â C:\WINNT\system32\ADVAPI32
0x7C570000 - 0x7C628000 Â Â Â Â C:\WINNT\system32\KERNEL32
0x77D30000 - 0x77DA1000 Â Â Â Â C:\WINNT\system32\RPCRT4.D
0x78000000 - 0x78045000 Â Â Â Â C:\WINNT\system32\MSVCRT.d
0x08000000 - 0x08136000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x77E10000 - 0x77E75000 Â Â Â Â C:\WINNT\system32\USER32.d
0x77F40000 - 0x77F7E000 Â Â Â Â C:\WINNT\system32\GDI32.DL
0x77570000 - 0x775A0000 Â Â Â Â C:\WINNT\system32\WINMM.dl
0x10000000 - 0x10007000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x007C0000 - 0x007CE000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x007D0000 - 0x007E8000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x007F0000 - 0x007FD000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x18270000 - 0x1837F000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x77800000 - 0x7781E000 Â Â Â Â C:\WINNT\system32\WINSPOOL
0x76620000 - 0x76630000 Â Â Â Â C:\WINNT\system32\MPR.DLL
0x75E60000 - 0x75E7A000 Â Â Â Â C:\WINNT\system32\IMM32.dl
0x77A50000 - 0x77B3F000 Â Â Â Â C:\WINNT\system32\ole32.dl
0x18380000 - 0x183D0000 Â Â Â Â C:\JBuilderX\jdk1.4\jre\bi
0x51000000 - 0x5104B000 Â Â Â Â C:\WINNT\system32\ddraw.dl
0x728A0000 - 0x728A6000 Â Â Â Â C:\WINNT\system32\DCIMAN32
0x5C000000 - 0x5C0C7000 Â Â Â Â C:\WINNT\system32\D3DIM700
0x20860000 - 0x20890000 Â Â Â Â C:\COLLEGE\attempt\cpp\gui
0x779B0000 - 0x77A4B000 Â Â Â Â C:\WINNT\system32\OLEAUT32
0x20890000 - 0x2094C000 Â Â Â Â C:\WINNT\system32\MSVCP71D
0x20950000 - 0x209D7000 Â Â Â Â C:\WINNT\system32\MSVCR71D
0x775A0000 - 0x77630000 Â Â Â Â C:\WINNT\system32\CLBCATQ.
0x65A60000 - 0x65A6A000 Â Â Â Â C:\WINNT\System32\wbem\wbe
0x65C20000 - 0x65CCD000 Â Â Â Â C:\WINNT\System32\wbem\wbe
0x77920000 - 0x77943000 Â Â Â Â C:\WINNT\system32\imagehlp
0x72A00000 - 0x72A2D000 Â Â Â Â C:\WINNT\system32\DBGHELP.
0x690A0000 - 0x690AB000 Â Â Â Â C:\WINNT\system32\PSAPI.DL
Heap at VM Abort:
Heap
 def new generation  total 576K, used 543K [0x10010000, 0x100b0000, 0x104f0000)
 eden space 512K,  93% used [0x10010000, 0x10087fa0, 0x10090000)
 from space 64K, 100% used [0x100a0000, 0x100b0000, 0x100b0000)
 to  space 64K,  0% used [0x10090000, 0x10090000, 0x100a0000)
 tenured generation  total 1408K, used 129K [0x104f0000, 0x10650000, 0x14010000
)
  the space 1408K,  9% used [0x104f0000, 0x10510740, 0x10510800, 0x10650000)
 compacting perm gen  total 4352K, used 4224K [0x14010000, 0x14450000, 0x1801000
0)
  the space 4352K,  97% used [0x14010000, 0x14430200, 0x14430200, 0x14450000)
Local Time = Sat May 01 18:38:55 2004
Elapsed Time = 5
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_01-b06 mixed mode)
#
# An error report file has been saved as hs_err_pid2492.log.
# Please refer to the file for further information.
#
Press any key to continue . . .
**************************
Any help is realy apreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER