JAVA NATIVE ACESS

HI,
I have a big problem with Java Native Access when call a function in dll file.
First, I have files xxx.dll,xxx.h (written by my partner) and document for functions.
Second, I am using JNA (java native access) to call the functions.
But, it has some functions that function's result is pass over memory of window.
In document description, it has tow constant: WM_USER = 0x0400, WM_USER_ENV = (WM_USER + 0)
I have just learn, so i don't know about that.
So, my problem is " i don't know how to get result of function that passed over to memory window )
This is my header file: “MFSIOCTL.h”
// Command
#define     CMD_VERSION               'V'
#define     CMD_SENSOR               'S'
#define     CMD_FLICKER               'L'
#define CMD_GETSTATUS          'A'
#define     DEST_1                    '1'          //front door / Card Reader Flicker Lamp
#define     DEST_2                    '2'          //UPPER FRAME IN POSITION(CDM) / Printer Lamp
#define     DEST_3                    '3'          //Receipt Exit Sensor / Cheque Lamp
#define     DEST_4                    '4'          //Cheque Door Sensor / A4 or Cash Lamp
#define     DEST_5                    '5'          //Bill Hopper Sensor - 2006/06/20 added
#define DEST_ALL               '0'          //Get all Status
//switch status or FLicker Lamp on/off
#define OPEN                    '0'          //Flicker Off
#define     CLOSE                    '1'          //Flicker On
//added at 2004/09/17
#define WM_MFS_IO_OFFSET                    (WM_USER+0x900)
#define     WM_MFS_IO_CHG_EVT                    (WM_MFS_IO_OFFSET + 0)
extern "C" __declspec(dllexport) BOOL __stdcall MFSIO_Open(HWND hWnd,BYTE comport);
extern "C" __declspec(dllexport) BOOL __stdcall MFSIO_Close(void);
extern "C" __declspec(dllexport) BOOL __stdcall MFSIO_GetVersion(LPSTR lpFWVer,LPSTR lpDLLVer);
extern "C" __declspec(dllexport) BOOL __stdcall MFSIO_LED(BYTE LEDNum,BYTE OnOff);
extern "C" __declspec(dllexport) BYTE __stdcall MFSIO_GetStatus(void);
And this is window message define:
--- Definition of Window Message
: Message is defined in “MFSIOCTL.h” as bellows.
#define WM_MFS_IO_OFFSET (WM_USER+0x900)
#define WM_MFS_IO_CHG_EVT (WM_MFSS_IO_OFFSET + 0)
MESSAGE WPARAM(Indicator ofDoor or Media) LPARAM(Status of Door or Media)
WM_MFSS_IO_CHG_EVT DEST_1 or OPEN or CLOSE
DEST_2 or
DEST_3 or
DEST_4
Refer to “MFSIOCTL.h”
In functions, i don't know that they relative with parameters as "WM_MSF_IO_OFFSET, WM_MFS_IO_CHG_EVT'' and parameters use for what?
How to get value of window message?
Please help me. Thank you.
Edited by: QuocTan on Sep 8, 2010 9:31 PM
Edited by: QuocTan on Sep 8, 2010 9:34 PM

But, it has some functions that function's result is pass over memory of window.I have no idea what that means. Please try again in standard English.
In document description, it has two constant: WM_USER = 0x0400, WM_USER_ENV = (WM_USER + 0)
These are Windows constants. I don't understand the relevance.
So, my problem is " i don't know how to get result of function that passed over to memory window)*My* problem is that this is about the 4th time I've read this statement and it doesn't make any sense. What is a 'memory window'? What is 'memory of window'?
#define WM_MFS_IO_OFFSET                    (WM_USER+0x900)
#define     WM_MFS_IO_CHG_EVT                    (WM_MFS_IO_OFFSET + 0)If these lines are the problem, they have nothing whatsoever to do with JNI or this forum.
In functions, i don't know that they relative with parameters as "WM_MSF_IO_OFFSET, WM_MFS_IO_CHG_EVT'' and parameters use for what?Eh?
How to get value of window message?What?
Please help me.I cannot help either of you until you take the trouble to express yourselves clearly in standard English. Your problem doesn't appear to have anything to do with JNI or JNA. More likely it is an elementary Windows API programming problem, which is irrelevant to this forum and this site.

Similar Messages

  • How to use the java native api

    i am new to the java native api, can anyone tell me how to use it in order for me to use the c++ file in the java file?please explain it if possible, thanks

    Try this out to learn the basics :
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    You can't go wrong from there.

  • Problem with Java Native Type after Migration from 7.0 to 7.1

    Hi,
    after Migration from Netweaver 7.0 to Netweaver 7.1 I get following error:
    FileDownload 'FileDownload.data': Context attribute 'PrintSelectedView.PdfToDownload.resourceInputStream' has the Java native type 'com.sap.tc.webdynpro.progmodel.api.IWDInputStream' and cannot be bound to this property. Hint: Remove the binding or bind a context element matching the property's type.     
    What have I done wrong?
    How could I fix this problem?
    Best regards,
    Peter

    Hi,
    thanks, this solved the problem.
    Thank you.
    Best regards,
    Peter

  • JAVA NATIVE ACCESS

    hi
    It would be helpfull for me if anybody give good reference/ link related JAVA NATIVE ACCESS
    i have tried through google and sun search but most of all are java native Interface...
    so please
    thanks in advance

    Hello guys,
    I have a problem in JNA to create interface method because i must search functions in DLL which have many structures as argument. So i find JNA is difficult but less than JNI.
    I would like to give you my specification file and traduce this fonction in the interface of JNA. Please help me !!!!
    Here is these C functions :
    typedef disco_err (WINAPIV* win_disco_init)(disco_init_conf_t* conf);
    typedef enum {
    DISCO_ERR_NONE = 0, //!< No error
    DISCO_ERR_IO = -1, //!< IO error
    DISCO_ERR_DB = -2, //!< Database error
    DISCO_ERR_MEM = -3, //!< Memory allocation error
    DISCO_ERR_PAR = -4, //!< Invalid parameters
    DISCO_ERR_ND = -5, //!< Max number of opened descriptors is
    reached
    DISCO_ERR_NS = -6, //!< Service not supported
    DISCO_ERR_ID = -7, //!< Bad id
    DISCO_ERR_FF = -8, //!< Bad file format
    DISCO_ERR_EOF = -9, //!< End of file
    DISCO_ERR_NOE = -10, //!< No such entity
    DISCO_ERR_INT = -11, //!< Database build interrupted
    DISCO_ERR_ACCESS = -12, //!< Access denied
    DISCO_ERR_EMPTY = -13, //!< Empty information
    DISCO_ERR_NO_MORE_RESPONDING_IPOD = -14, //!<no more iPod
    DISCO_ERR_OTHER = -30, //!< Other
    }disco_err;
    typedef struct {
    disco_uart_iap_init iap_via_uart;//! Unused
    int priority; //!< Priority level of Disco threads
    disco_spec_strs_t strs; //!< Special strings configuration
    }disco_init_conf_t;
    typedef struct {
    const char* empty; //!< String for undefined lists elements
    const char* root; //!< Name for virtual 'Root' directories
    }disco_spec_strs_t;
    So it's a real crazy mapping between C and Java. It's too dificult for me. i hope there will be a professional of mapping ? Give me the solution please because i have 20 days to design the modul of my java application.
    thanks in advance,
    Nicolas.

  • JAVA NATIVE TYPES

    Hi everyone,
    Can anyone let me know what are java native types and its purpose?
    Regards,
    Subrat

    Hi Subrat,
    I assume you are asking about the Java Native Types option while creating context attribute. Java native types give you the ability to assign the Java Classes as types for your context attributes. that means you can create your context attributes based on Java Classes. They are useful when you have to store some data in the context attributes for which no direct type is given by Web Dynpro.
    Regards,
    Ajay

  • Execution of Java Native Process slow in Mac OS X

    Hi,
    I'm having some performance issues when executing an java native process on Mac OS X. I am developping an application in AIR that searches for people in the ldap of our organisation. It has to be usable both on Mac as on Windows. When I execute my app on windows, the search process takes about 2-3 seconds. However, when I try to execute it on mac, the search process takes about 6-8 seconds. This is a bit to long to make it usable.
    Has anybody encountered this problem as well and does anyone know what the problem can be?
    Thanks in advance
    Ronald Kamp
    Junior Flex/Java/LiveCycle Consultant at iDA MediaFoundry

    Hi Ronald,
    Have you tried benchmarking your java process without the inclusion of AIR?  If so, did you find a difference which points to AIR being a culprit for the performance hit?
    I'd be very interested in trying this out.  If you could provide me with a sample project that illustrates the slow down on Mac, I'll take a look right away.  Please feel free to contact me via private message on the forum or at [email protected] if you'd like to take this offline.
    Thanks,
    Chris

  • HELP : "LINUX BASH COMMANDS" Java Native Interface

    how can i create a program using Java Native Interface that could run or recognize LINUX BASH COMMANDS

    Runtime.getRuntime().exec(<command>); But read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Libumem and java native leaks

    I'm diagnosing a native memory leak in a java process(not caused by a user JNI library, probably due to not closing some stream tied to native resources). I had used this technique before with some success, but this time I'm running into some problems. Basically what I'm doing is using libumem and mdb to help find the leak. I realize that these tools can give some strange results when looking at the JVM, but previously when I have it used, I can just focus on the leaked buffers with a large count and that pointed me right to the problem(the problem is bad enough that eventually I run out of memory space for the process...so I know the leak is being triggered repeatedly). The first problem I have is with libumem/mdb and the stack printed out through bufctl_audit which only displays symbol addresses for java routines. If it displayed the java symbol names, or if there were a way to make it display them then I wouldn't have much of a problem(though I've found I need to increase the audit size because of the large stack frame for a java process).
    So what I've done before is find the C library/routines where the memory is being leaked at, and then use dtrace to print stack traces for calls into that C library. Something like this:
    dtrace -n 'pid$target:libzip:ZIP_GetEntry:entry { @s[jstack(60,3000)] = count() }' -p <PID>
    This has pointed me to the right place in the past, because the place where the leak was happening was getting called frequently. The problem is with the current leak is this is much too course grained. The C library being called is being called quite often, so I'm getting way too many stacks, and sorting through to find the problematic one is difficult. Now if jstack() would show the java symbol name AND its address I could easily correlate it with what's in the findleaks/bufctl_audit output of libumem/mdb.
    Is there something I can do inside mdb to help find the java symbol names, or is there a way to use dtrace to correlate the java symbol name with its address to help me out here? I can do some rather ugly iterative stuff with dtrace where I don't give it a large enough buffer to print the whole stack trace and with small increases probably find the mappings from the java symbols to the address, but I was hoping there was something a little less painful. This of course needs to be diagnosed in a production system...so what I can do is somewhat limited. There is redundancy, so I obviously can for a short period pause execution on one server to grab the findleaks output and things like that. Thanks,
    Micah

    Since your question is about tracing Java internals, you might do better posting in a Java-related forum. (This forum is for Sun Studio, for developing in C, C++, and Fortran.) Try one of the forums listed under Java here:
    [http://forums.sun.com/index.jspa?tab=forums]
    and especially here:
    [http://forums.sun.com/category.jspa?categoryID=39]

  • How to access android resource in java native extension....??

    hi..
    i want access android resource..
    for example, res/menu/menu.xml, res/values/strings.xml ... etc...
    - R.java -
    /* AUTO-GENERATED FILE.  DO NOT MODIFY.
    * This class was automatically generated by the
    * aapt tool from the resource data it found.  It
    * should not be modified by hand.
    package com.flash.extension.nativelib;
    public final class R {
        public static final class attr {
        public static final class drawable {
            public static final int icon=0x7f020000;
            public static final int notification_icon=0x7f020001;
        public static final class layout {
            public static final int main=0x7f030000;
        public static final class string {
            public static final int extension_app_name=0x7f040001;    -> "hi extension"
            public static final int extension_hello=0x7f040000;
    so i used getResourceId("string.extension_app_name");
    but it's not work.. throw NotFoundException error..
    so i used context.getString(R.string.extension_app_name);
    it's work, but return incorrect value.. -> return value is "0.0.0".. it's versionName in actionScript Client Project..
    why can't access android resource in native extension?
    how to get android resource in java natvie extension..??
    Is there anyone who has a sample source??
    help.. me.. please..

    Hello,
    I am facing the same issue with the native extension i am using follwing code to get the resource id
             Intent inte = new Intent(context.getActivity().getApplicationContext(),SecondActivity.class);
              inte.putExtra("layout",context.getResourceId("layout.secondactivity"));
              context.getActivity().startActivity(inte);
    i am getting this exception "android.content.res.Resources$NotFoundException:layout.secondactivity"
    I have included activity in the native manifest file as well as flex's manifest file for android.
    please help me with this or an example will be great thanks.

  • Java application hangs during running java native method

    Hello,
    There is compiled java application.
    It hangs at very begginings.
    It was detected that in the beggining a new Frame should be created. Then one java library invokes native method. During invoking of the native method application hangs.
    Stack is available only until native method invocation.
    Thread 25196 "main": (state = IN_NATIVE)
    at sun.awt.X11GraphicsDevice.getDoubleBufferVisuals(Native Method)
    at sun.awt.X11GraphicsDevice.getDefaultConfiguration(X11GraphicsDevice.java:181)
    at java.awt.Window.init(Window.java:271)
    at java.awt.Window.<init>(Window.java:319)
    at java.awt.Frame.<init>(Frame.java:419)
    at javax.swing.JFrame.<init>(JFrame.java:194)
    at com.test.ORBManager.Splash.<init>(Splash.java:10)
    at com.test.ORBManager.Splash.main(Splash.java:48)
    Method getDoubleBufferVisuals(int screen) is used to enumerates all visuals that support double buffering (according to comments in the source code).
    Tried to run with "-verbose" options...
    I tried to use jconsole &#1080; jvisualvm. But did not find anything special.
    Also "strace" command showed some results but do not know how to proceed:
    select(6, [5], [5], NULL, NULL) = 1 (out [5])
    writev(5, [{"b\0\6\0\r\0\0\0DOUBLE-BUFFER\0\0\0", 24}], 1) = 24
    select(6, [5], [], NULL, NULL) = 1 (in [5])
    read(5, "\1\0\t\0\0\0\0\0\1\211\0\204\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096) = 32
    read(5, 0x83b57bc, 4096) = -1 EAGAIN (Resource temporarily unavailable)
    gettimeofday({1275494877, 569746}, NULL) = 0
    select(6, [5], [5], NULL, NULL) = 1 (out [5])
    writev(5, [{"b\0\6\0\r\0\0\0DOUBLE-BUFFER\0\0\0", 24}], 1) = 24
    select(6, [5], [], NULL, NULL) = 1 (in [5])
    read(5, "\1\0\n\0\0\0\0\0\1\211\0\204\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096) = 32
    read(5, 0x83b57bc, 4096) = -1 EAGAIN (Resource temporarily unavailable)
    select(6, [5], [5], NULL, NULL) = 1 (out [5])
    writev(5, [{"\211\6\3\0\1\0\0\0&\0\0\0", 12}], 1) = 12
    select(6, [5], [], NULL, NULL) = 1 (in [5])
    read(5, "\1\0\v\0\f\0\0\0\1\0\0\0\377\32\0\0\377\r\307 \0\0\0\0\0\23\372\300\376\3346\34"..., 4096) = 44
    read(5, 0x83c31e4, 36) = -1 EAGAIN (Resource temporarily unavailable)
    select(6, [5], NULL, NULL, NULL) = ? ERESTARTNOHAND (To be restarted)
    I have downloaded from the internet the source code of native method but do not know what I can do with it.
    Is it possible to debug native method somehow?
    How to detect where the library contans the native method is located?
    What other ways can provide more information about reason.
    It seems that the problem is related to graphics. Judging by class name "X11GraphicsDevice" it is related to X server. May be some server settings?
    The problem is present on SLED 11 machines.
    It is not reproduced on SLED 10.
    I will be really appreciate for any help.
    Thanks in advance.
    Vasily.

    Hi,
    Thanks for tip. I used jstack. It gives a little bit more info but I have to few knoledges how to treat the info.
    ----------------- 24231 -----------------
    ----------------- 24317 -----------------
    0xffffe430     ????????
    0x6dd12229     ????????
    0xb0ca5898     * java.net.PlainSocketImpl.socketAccept(java.net.SocketImpl) bci:0 (Interpreted frame)
    0xb0c9fb6b     * java.net.PlainSocketImpl.accept(java.net.SocketImpl) bci:7 line:384 (Interpreted frame)
    0xb0c9fb6b     * java.net.ServerSocket.implAccept(java.net.Socket) bci:50 line:450 (Interpreted frame)
    0xb0c9fb6b     * java.net.ServerSocket.accept() bci:48 line:421 (Interpreted frame)
    0xb0c9fa94     * sun.rmi.transport.tcp.TCPTransport.run() bci:59 line:340 (Interpreted frame)
    0xb0c9fe71     * java.lang.Thread.run() bci:11 line:595 (Interpreted frame)
    0xb0c9d236     <StubRoutines>
    0xb6f38eac     _ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread + 0x1bc
    0xb7108aa8     _ZN2os20os_exception_wrapperEPFvP9JavaValueP12methodHandleP17JavaCallArgumentsP6ThreadES1_S3_S5_S7_ + 0x18
    0xb6f38705     _ZN9JavaCalls12call_virtualEP9JavaValue11KlassHandle12symbolHandleS3_P17JavaCallArgumentsP6Thread + 0xd5
    0xb6f3879e     _ZN9JavaCalls12call_virtualEP9JavaValue6Handle11KlassHandle12symbolHandleS4_P6Thread + 0x5e
    0xb6fb0765     _Z12thread_entryP10JavaThreadP6Thread + 0xb5
    0xb71a9373     _ZN10JavaThread3runEv + 0x133
    0xb71096b8     _Z6_startP6Thread + 0x178
    0xb781a1b5     start_thread + 0xc5
    ----------------- 24318 -----------------
    0xffffe430     ????????
    0x1b7bfaf0     ????????
    ----------------- 24373 -----------------
    0xffffe430     ????????
    0xb71087be     _ZN2os5Linux14safe_cond_waitEP14pthread_cond_tP15pthread_mutex_t + 0xae
    0xb70fe2af     _ZN13ObjectMonitor4waitExiP6Thread + 0xa6f
    0xb718bdc6     _ZN18ObjectSynchronizer4waitE6HandlexP6Thread + 0x56
    0xb6f925e3     JVM_MonitorWait + 0x163
    0xb0ca5898     * java.lang.Object.wait(long) bci:0 (Interpreted frame)
    0xb0c9fb6b     * java.lang.ref.ReferenceQueue.remove(long) bci:44 line:120 (Interpreted frame)
    0xb0c9fa94     * java.lang.ref.ReferenceQueue.remove() bci:2 line:136 (Interpreted frame)
    0xb0c9fa94     * sun.java2d.Disposer.run() bci:3 line:125 (Interpreted frame)
    0xb0c9fe71     * java.lang.Thread.run() bci:11 line:595 (Interpreted frame)
    0xb0c9d236     <StubRoutines>
    0xb6f38eac     _ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread + 0x1bc
    0xb7108aa8     _ZN2os20os_exception_wrapperEPFvP9JavaValueP12methodHandleP17JavaCallArgumentsP6ThreadES1_S3_S5_S7_ + 0x18
    0xb6f38705     _ZN9JavaCalls12call_virtualEP9JavaValue11KlassHandle12symbolHandleS3_P17JavaCallArgumentsP6Thread + 0xd5
    0xb6f3879e     _ZN9JavaCalls12call_virtualEP9JavaValue6Handle11KlassHandle12symbolHandleS4_P6Thread + 0x5e
    0xb6fb0765     _Z12thread_entryP10JavaThreadP6Thread + 0xb5
    0xb71a9373     _ZN10JavaThread3runEv + 0x133
    0xb71096b8     _Z6_startP6Thread + 0x178
    0xb781a1b5     start_thread + 0xc5
    ----------------- 24227 -----------------
    0xffffe430     ????????
    0x6cbc4021     ????????
    0x6cbc232a     ????????
    0x6cbc3c9a     ????????
    0x6cc1d5d1     ????????
    0x6d41013f     ????????
    0x6d460f19     ????????
    0xb0ca5898     * sun.awt.X11GraphicsDevice.getDoubleBufferVisuals(int) bci:0 (Interpreted frame)
    0xb0c9fb6b     * sun.awt.X11GraphicsDevice.getDefaultConfiguration() bci:140 line:181 (Interpreted frame)
    0xb0c9fa94     * java.awt.Window.init(java.awt.GraphicsConfiguration) bci:51 line:271 (Interpreted frame)
    0xb0c9fb6b     * java.awt.Window.<init>() bci:66 line:319 (Interpreted frame)
    0xb0c9fb6b     * java.awt.Frame.<init>(java.lang.String) bci:1 line:419 (Interpreted frame)
    0xb0c9fb6b     * javax.swing.JFrame.<init>(java.lang.String) bci:2 line:194 (Interpreted frame)
    0xb0c9fb6b     * com.test.ORBManager.Splash.<init>() bci:3 line:10 (Interpreted frame)
    0xb0c9fb6b     * com.test.ORBManager.Splash.<init>(java.lang.String[]) bci:4 line:48 (Interpreted frame)
    0xb0c9d236     <StubRoutines>
    0xb6f38eac     _ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread + 0x1bc
    0xb7108aa8     _ZN2os20os_exception_wrapperEPFvP9JavaValueP12methodHandleP17JavaCallArgumentsP6ThreadES1_S3_S5_S7_ + 0x18
    0xb6f38cdf     _ZN9JavaCalls4callEP9JavaValue12methodHandleP17JavaCallArgumentsP6Thread + 0x2f
    0xb6f638b2     _Z17jni_invoke_staticP7JNIEnv_P9JavaValueP8_jobject11JNICallTypeP10_jmethodIDP18JNI_ArgumentPusherP6Thread + 0x152
    0xb6f54ac2     jni_CallStaticVoidMethod + 0x122
    0x08049873     ????????
    0xb76c9705     ????????The last stack also has "sun.awt.X11GraphicsDevice.getDoubleBufferVisuals(int) bci:0 (Interpreted frame)" but what tode next?
    Also I found that the native code is in java 1.5 source code: \j2se\src\solaris\native\sun\awt\awt_GraphicsEnv.c.
    How it is possible to compile it?

  • JAVA NATIVE COMPILER

    Hello,
    Is there a compiler for compiling my JAVA program in native code for win32 and Linux(x86).(free or not)
    I use SWING for the interface.
    Best regards

    Hi,
    I am not sure of a direct compiler but you can do this in two steps.
    1. Compile your Java Source into normal Java Classes using any of the normal Java Compilers.
    2. Convert these Byte code files (Java Classes) into executable files.
    There are a few options for doing this sort of thing...
    Windows
    http://www.excelsior-usa.com/jetdl.html
    ..more information about this can be obtained under the FAQ section...
    http://www.excelsior-usa.com/jetfaq.html#id2
    Another options is...
    http://www.bravozulu.com/Products/JToExe/Download/download.html
    with information about it at...
    http://www.bravozulu.com/Products/JToExe/jtoexe.html
    Unix
    Not sure of any Free stanalone programs for Unix flavours but there is an alternative here...
    http://www.ifrance.com/vonarnim/vainstall/
    Hope this helps.
    Best Regards,
    Manish

  • Java Native Interface Exception Access Violation

    Ok i have two programs One that works and one that dosn't
    the one that works is a javaMethod that calls a C method. the C method then uses a callsback on a java method that returns an array of integers. that works fine
    the Second program uses the same c side code and the same Java Methods from the original are implemented into a program i have that runs a Jframe. anyways when i run this program the Native side does all of its tasks but when its done it crashes Evrything
    here is the Native Code
    #include <jni.h>
    #include "MyNativeInterface.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_MyNativeInterface_sayHello(JNIEnv *env, jobject obj)
    printf("Hello world!\n");
    return;
    JNIEXPORT void JNICALL
    Java_MyNativeInterface_nativeMethod(JNIEnv *env, jobject obj)
    jintArray arr;
         jint len;
         int *carr;
         int i;
    jclass cls = (*env)->GetObjectClass(env, obj);
    jmethodID mid =
    (*env)->GetMethodID(env, cls, "callback", "()[I");
    if (mid == NULL) {
    return; /* method not found */
    printf("In C\n");
    arr = (*env)->CallObjectMethod(env, obj, mid);
         len = (*env)->GetArrayLength(env,arr);
         printf("Array Length = %d\n",len);
         carr = (int*)malloc(len);
         (*env)->GetIntArrayRegion(env,arr,0,len,(jint*)carr);
         for (i=0;i<len;i++)
    printf("Array position %d is %d \n",i,carr);
    and here is the java class that deals with the native side
    import java.util.*;
    public class MyNativeInterface extends Object {
    private TextAreaDemo gui ;
    public MyNativeInterface (TextAreaDemo guiRecieved)
    gui = guiRecieved;
    static {
    System.loadLibrary("hello");
    public boolean sendLocoMessage ( byte [] bytesToSend )
    try {
    System.out.println("number Of Tokens ="+bytesToSend [0]);
    } catch (Exception e) {
    System.out.println("didn't even get inside2 ok ");
    return true;
    public void receiveLocoMessage ( byte [] bytesToSend ){
    gui.AddMessage ("WOOOOO HOOOOOO");
    public native static void sayHello ();
    public native void nativeMethod();
    private int [] callback() {
    int cools [] = new int [32] ;
    int i = 0 ;
    for (i=0;i<32;i++)
    cools [i] = i;
    //System.out.println("In Java");
    return cools;
    the Say Hello Method works just fine
    and the array for the C side prints out just fine
    then evrything crashes with the following message
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D3276E4
    Function=ZIP_Open+0x107
    Library=c:\j2sdk1.4.0_01\jre\bin\zip.dll
    and a whole BUNCH of current java thread stuff and a list of dynamic libraries.
    anyways thanks

    Your C code asks for the length of the array, then
    allocates that many BYTES using malloc. This looks
    bogus to me.I agree.
    Maybe something like this would be better:
    carr = (int*)malloc(len * sizeof jint);

  • Java native -- please help

    class HelloWorld {
    private native void print();
    public static void main(String[] args) {
    new HelloWorld().print();
    static {
    System.loadLibrary("HelloWorld");
    //this is .h file
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <C:\java\jdk1.5.0_06\include\jni.h>
    /* Header for class HelloWorld */
    #ifndef IncludedHelloWorld
    #define IncludedHelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: HelloWorld
    * Method: print
    * Signature: ()V
    JNIEXPORT void JNICALL Java_HelloWorld_print
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    //this is .h file end
    // C File starts
    #include "C:\java\jdk1.5.0_06\include\jni.h"
    #include <stdio.h>
    #include "HelloWorld.h"
    JNIEXPORT void JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    //C file ends
    I have used following commands to create dll
    cl -I"C:\Program Files\Microsoft Visual Studio 8\VC\include" -I"C:\java\include\win32"
    -I"C:\java\jdk1.5.0_06\include\win32" -I"C:\Program Files\Microsoft SDKs\Windows\v6.0\Include" HelloWorld.c
    -FeHelloWorld.dll -LDd -MD -link -libpath:"C:\Program Files\Microsoft SDKs\Windows\v6.0\VC\LIB"
    -libpath:"C:\Program Files\Microsoft Visual Studio 8\VC\lib"
    At runtime I get error the " an atempt has made to load a C library in correcty" and then error
    "A dynamic link library (DLL) initialization routine failed"
    please help me ASAP.
    thanks in advance.

    class HelloWorld {
    private native void print();
    public static void main(String[] args) {
    new HelloWorld().print();
    static {
    System.loadLibrary("HelloWorld");
    //this is .h file
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <C:\java\jdk1.5.0_06\include\jni.h>
    /* Header for class HelloWorld */
    #ifndef IncludedHelloWorld
    #define IncludedHelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: HelloWorld
    * Method: print
    * Signature: ()V
    JNIEXPORT void JNICALL Java_HelloWorld_print
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    //this is .h file end
    // C File starts
    #include "C:\java\jdk1.5.0_06\include\jni.h"
    #include <stdio.h>
    #include "HelloWorld.h"
    JNIEXPORT void JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    //C file ends
    I have used following commands to create dll
    cl -I"C:\Program Files\Microsoft Visual Studio 8\VC\include" -I"C:\java\include\win32"
    -I"C:\java\jdk1.5.0_06\include\win32" -I"C:\Program Files\Microsoft SDKs\Windows\v6.0\Include" HelloWorld.c
    -FeHelloWorld.dll -LDd -MD -link -libpath:"C:\Program Files\Microsoft SDKs\Windows\v6.0\VC\LIB"
    -libpath:"C:\Program Files\Microsoft Visual Studio 8\VC\lib"
    At runtime I get error the " an atempt has made to load a C library in correcty" and then error
    "A dynamic link library (DLL) initialization routine failed"
    please help me ASAP.
    thanks in advance.

  • Network Java Native Library libnet.jnilib source code or functions name

    Hi,
    I am using libnet.jnilib in my networking project but i am not aware about the internal structure of this library. Is this open source library? Is oracle JNI project open source as jdk? If It is, Where can i get source code for that? If It is not, Can u help me to get the methods name and signatures for the libnet.jnilib library?
    Thank you,
    Gaurav

    You're looking in the wrong place, so it's pointless. You can't get any information about what the TCP/IP stack is doing at the network layer or what the NIC is doing at the physical layer from Java's native code. All it does is call the C Sockets API. It is essentially part of the application, not part of the operating system or network layer or physical layer, and it doesn't know any of those from Adam.
    You need to attach some drivers into the network stack to get that kind of information. All that you could get by instrumenting Java's native networking code is the flow of data into and out of the application, and you can get that via network stack drivers too. You should also have a look at the several implementations of Jpcap.

  • Passing a java native error

    im updating a db with a stored proc call
    and one field in my db is a err_desc column to pass native java errors to the db
    should i be passing in the Exceptions here or am i going about this wrong???
    any suggestions - thanks in advance
         public static int updateStatus()
              Connection conn = null;
              int statcodeout = 0;
              try
                   conn = getDbConnection(USERID, PWD, SERVER);
                   CallableStatement cs = conn.prepareCall("{CALL " + UPDATE + "(?, ?, ?, ?, ?, ?, ?, ?, ?)}");
                   cs.setInt(1,getId());
                   cs.setInt(2,0);
                   cs.setInt(3,0);
                   cs.setString(4, err_desc);//String to pass native error to??
                   cs.setString(5,SERVER);
                   cs.setString(6,DIR);
                   cs.setString(7,getName());
                   cs.setInt(8,getFileSize());
                   cs.setInt(9,0);
                   cs.registerOutParameter(9, Types.INTEGER);     
                   cs.executeUpdate();
                   statcodeout = cs.getInt(9);
                   cs.close();     
              catch(Exception e)
                   e.printStackTrace();
              finally
                   try
                        conn.close();
                   catch(SQLException sqle)
                        sqle.printStackTrace();
              return statcodeout;
         }

    yea - that is why im confused too - it should not update
    if it fails right??? i Aye.
    think my instuctoins were not clear??Aye
    but i started to do something like thisAye, I use this:
         final StringWriter sw = new StringWriter();
         throwable.printStackTrace( new PrintWriter( sw ) );
         String s = sw.toString();for an email alert.
    im going to have to ask again, Aye :-)

Maybe you are looking for

  • Trying to download windows vista premium on macbook pro

    i just bought windows vista premium from microsoft market place then tried to download it .... not working ... please advise

  • RMBP Late 2013 Facetime HD Camera Not Working

    Hi there, I have my rMBP since the end of December. When I got it, i needed to update the OS X to 10.9.1. I don't recall if i tried the FaceTime HD Camera later or before the system update, but i'm sure it was working back then. Now it doesn't work.

  • Song shows up on computer but not iPhone

    I downloaded several songs today. They all downloaded and show up on my computer and play just fine. They all synced to the phone except one. I have restarted my computer and iPhone, made sure my phone was up to date, resynced several times. I manual

  • Why does the PDFs' name change when i view them in the iBooks app?

    i have some past papers and marking schemes in my iTunes library....when i sync them to my iPad, they appear just fine....they are there just the way i named them and all... but when i open them, the name changes to some coded-ish name with lots of n

  • Air update phone firmware version

    How do you update phone firmware version? 1. Download Nokia pc suite and use NSU or Nokia ovisuite (For Windows User only) 2. Try over the Air update (MAC/Windows User) If your mobile data rates allow, try doing an over the air update. Support varies