Multithreaded Java app calling C via JNI...need help!

I have a multithreaded Java app making a JNI call into some C code. It is a high speed imaging algorithm that I simply can't/don't want to do in Java. I am very new to JNI and I am hoping to get some expert advice on how to solve this issue. Basically, I need a seperate JNI session (if that is such a thing) per thread. In other words, I need to essentially keep state of each JNI call as it pertains to the current thread.
The 2 ideas I have thought about are:
1. Have the native code pass the data back into java, and have the java object hold it. Then, when subsequent native calls are made, you pass the data as a paramter of the native method.
(This can be painful as it a lot of complicated and/or a lot of data.)
2. Define some sort of a structure to hold each instance of the data on the C side, returning to java a lookup key. Subsequent native calls include the key as a paramter, and the data is looked up. ( a quick example of this would be nice).
I would appreciate any information/expereince/pains with this one.
Thanks!

2. Define some sort of a structure to hold each instance of the data on the C side, returning to java a lookup key. Subsequent native calls include the key as a paramter, and the data is looked up. ( a quick example of this would be nice).The lookup key, or a simple "pointer", can be returned to Java as a plain old "int" or "long" (I don't know what is the size of the pointers in your platform, if 32 or 64-bit). So you can return a "long", that can be treated by Java programs as an "opaque handle" (a pompous name for things that can't be handled adequately at the "client" side).
I assume that C/C++ allocates the memory and it remains "fixed" (untouched by garbage collection) between calls. So a real C pointer can be used in such case. If you have some smarter scheme of allocating things in your program, return another kind of lookup key (for instance, if you allocate things in fixed-size C arrays, you can return the index of the C object in the array instead of returning a plain pointer.

Similar Messages

  • Please I'm from Ecuador and I can't put my credit card en App Store. Please I need help  

    Please I'm from Ecuador and I can't put my credit card en App Store. Please I need help  

    Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • I cant download applications in app store!! i need help cuz i wanna play gamessss!! can someone help??

    ok so... I just download the App Store for Mac because I wanted to play games and stuff, so I have the Apple ID, and I have iTunes, but once I clicked on a free app to down load it says "Your request is temporarily unable to be processed.Please try again later." and then 2 seconds later it says "We could not complete your request.There was an error in the App Store. Please try again later. (100)" so yepp i need help... plezz

    Maybe it is down. Try tomorrow.
    Are you visually impaired? If not, please do not write posts in ridiculously large type.

  • FB app closing by itself, I need help

    So its been about 3 weeks since I updated my FB app on my Iphone4, and for some reason it keeps closing by itself, I am getting annoyed by the fact that every time I want to use the app it just closes. I already tried deleting the app, downloading it again, and I do not what else to do. Please I need help!!

    Can I do this "fix" myself, or at least buy the part somewhere so that someone else who is good with computers can do it for me?
    This is the solution other people with this problem had. 
    Computer repair sent one user this message "Tested without touch panel, hdd, ram, keyboard light. Ordered new motherboard, however discovered that the computer started fine without touchpanel, seems like on/off switch is oversensitive.
    Power membrane switch is replaced, and everything is checked and OK."
    So- power membrane was to blame, and I guess this is just the "underneath" section of the panel of the external power, volume buttons at the top of my key board right?
    "Yes my issue was resolved. They replaced the power button strip above the keyboard which has eliminated the random shutdowns. Funny thing is that they had it less than 24 hours and seems like the "failure analysis engineer" immediately knew what the problem was. I feel sorry for the uneducated who fork over money for unneeded repairs."
    So, since Toshiba seems to try to make you pay 400 dollars to replace a motherboard etc. which won't fix the true problem, is there a site where I can buy the power membrane for my laptop, then take the computer and a part to a repair shop and they will do it?

  • ITunes App Store Gift Card, I need help, really.

    Okay, so I got two iTunes giftcards for Christmas, yes a while ago. But now, I needed the iTunes cash, so I redeemed them. Well, the first one, was $10, I got my money fine. Now, this one is $15. Now, here's the problem, I need help. I have two major things to say, first off, I peeled the stupid label off (I think peel it stupid, it should be scratch) and some parts of the letters got peeled off, but that's not the huge issue. The issue is I think some whole number/letters got peeled off, because the code is like thing NNNNN NNNNNNN NNN. Okay, I'm not saying the code, for obvious reason, but "N" just means number or letter. So basically there are 5 characters, space, 7 characters, space, then 3. I think this is odd, because my other code was on whole code, not spaces. Also, the spaces have room for other characters. Some letters are also messed up a bit, like an "M" is losing a bit of the leg to the right. Then a S, is missing basically a whole half. Now, can someone tell me if the code for App Store is supposed to be 5, 7, 3. If not, can I get a refund, or a new card from Apple?

    Click here and submit a request.
    (56608)

  • Getting the text of a java exception into C++ via JNI - how ?

    I have a C++ application that needs to create and call Java objects. If there is an exception in a Java method I want to be able to get the text of the exception's message for reporting an error to the C++ application user. The problem is, I can't get the methodID of the 'getMessage' method in the Throwable class.
    This is how I am tryng to get it:
    // Relevant exception-handling variables:
    jthrowable exceptionHandle;
    jclass jThrowableClass;
    jmethodID methodID;
    //Invoke the Java object
    env->CallVoidMethod( obj, methodID, args );
    //Check for an exception
    if ( (exceptionHandle = env->ExceptionOccurred()) != NULL )
    jThrowableClass = env->GetObjectClass( exceptionHandle );
    methodID = env->GetMethodID( jThrowableClass, "getMessage", "()Ljava/lang/String;" );
    // methodID is always NULL -- why??At this point, it can't go any further because the methodID is always NULL.
    I've tried several things, such as explicitly including rt.jar in the classpath when initializing the VM (I'm using JDK 1.3.1 and JNI 1.2) as well as copying rt.jar to the directory where the application's java VM code is at, but no luck there. I've also tried FindClass( "java/lang/Throwable") but that returned NULL so doesn't get as far as the code example here.
    How do you get the methodID of a method in a java language class like java.lang.Throwable ? Is there some initialization you need to do with the classpath ?
    Many thanks,
    Colm.

    When you program in Java you can use java.lang.reflect.
    For example, having a method named "met1" with 2 parameters, you can assign an object Method in this way:
    import java.lang.reflect.Method;
    Method comp = o1.getClass.getMethod("met1", param1.getClass(), param2.getClass());So with Throwable you could try something like: Throwable.class.getMethod("getMessage")Sorry but I am not so strong in C++ and I cannot give you help about it.
    The Java API documentation for the reflect package is at: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/package-frame.html
    Hoping to be helpful
    giangio

  • Java and C++  interface via JNI

    I am getting an "Runtime Error !" no other error message when I ran the C++ program creating JVM.
    Line in "m_env->CallStaticObjectMethod(clsABNLogger,midABNLogger,jstrLoggingLevel); "
    I have attached the code snippet.
    Anybody has experienced this error. ? Please post here!!
    JDK - 1.3
    JRE - 1.3_07
    MS VC++ 6.0 with Vstudio environment.
    Thanks!
    ---Code snippet --------
    // JNI Initialization
              m_jvm = 0;
              m_env = 0;
              jint res = -1;
         //     --more code
    res = JNI_CreateJavaVM(&m_jvm,(void **)&m_env,&vm_args);
    // Create the AgentDoc
    // ===================
    pDoc = new AAgentDoc(m_env,m_jvm);
              CString cstrLogFile;
              GetRegistryString("SOFTWARE\\ABN AMRO\\Call Center\\Business Layer", "Logging", cstrLogFile, FALSE, (HKEY)HKEY_LOCAL_MACHINE);
              if(cstrLogFile == "Y")
                   CString sErrorLevel = "";
                   GetRegistryString("SOFTWARE\\ABN AMRO\\Call Center\\Business Layer", "LoggingLevel", sErrorLevel, FALSE, (HKEY)HKEY_LOCAL_MACHINE);
                   sErrorLevel.MakeUpper();
                   if(sErrorLevel.Find("WINDOW") != -1)
                        jclass clsRuntime = JNIIDCache::getClass(m_env,"java/lang/Runtime");
                        jmethodID midRuntime = JNIIDCache::getMethodID(m_env,"getRuntime",clsRuntime,"()Ljava/lang/Runtime;","java/lang/Runtime", true);
                        jobject runtime = m_env->CallStaticObjectMethod(clsRuntime, midRuntime);
                        midRuntime = JNIIDCache::getMethodID(m_env,"exec",clsRuntime,"(Ljava/lang/String;)Ljava/lang/Process;","java/lang/Runtime");                    
                        CString sCommand = "java.exe -classpath " + classpathVar2 + " " + cstrSecuritypolicypath + " com.abnamro.na.cc.CallCenter.TheOracle.Classes.Util.DebugMain";//-Djava.rmi.server.codebase=file:/c:\\Cockpit\\source\\CallCenter\\TheOracle\\classes\\TheOracle.jar com.abnamro.na.cc.CallCenter.TheOracle.Classes.Util.DebugMain";
                        //CString sCommand = "java.exe -classpath c:\\Cockpit\\source\\callcenter\\theoracle\\classes\\TheOracle.jar -Djava.security.policy=C:\\Cockpit\\Source\\CallCenter\\theoracle\\classes\\java.policy com.abnamro.na.cc.CallCenter.TheOracle.Classes.Util.DebugMain";
                        //AfxMessageBox(sCommand);
                        jstring jstrCommand = m_env->NewStringUTF(sCommand.GetBuffer(sCommand.GetLength()));
                        jobject process = m_env->CallObjectMethod(runtime, midRuntime, jstrCommand);
                        // Wait for the debug server to start
                        Sleep(10000);
                   jclass clsABNLogger = JNIIDCache::getClass(m_env,"com/abnamro/na/cc/CallCenter/TheOracle/Classes/Util/ABNLogger");
                   if(clsABNLogger == NULL)
                        std::string Msg = "Unable to find ABNLogger class";
                        TRACE(Msg.c_str());
                        EventLogger.LogMsg(MSG_GENERAL_ERROR,EVENTLOG_WARNING_TYPE,MSG_GENERAL,m_sVersion,__FILE__,__LINE__,NULL,NULL,Msg.c_str(),NULL);
                        return retval;
                   jmethodID midABNLogger = JNIIDCache::getMethodID(m_env,"setLoggingLevel",clsABNLogger,"(Ljava/lang/String;)V","com/abnamro/na/cc/CallCenter/TheOracle/Classes/Util/ABNLogger", true);
                   if(midABNLogger == NULL)
                        std::string Msg = "Unable to set the logging level";
                        TRACE(Msg.c_str());
                        EventLogger.LogMsg(MSG_GENERAL_ERROR,EVENTLOG_WARNING_TYPE,MSG_GENERAL,m_sVersion,__FILE__,__LINE__,NULL,NULL,Msg.c_str(),NULL);
                        return retval;
                   jstring jstrLoggingLevel = m_env->NewStringUTF(sErrorLevel.GetBuffer(sErrorLevel.GetLength()));
                   m_env->CallStaticObjectMethod(clsABNLogger,midABNLogger,jstrLoggingLevel);
                   if(m_env->ExceptionOccurred())
                        m_env->ExceptionDescribe();

    Hello
    My problem was resolved.!!!
    Reason was I had multiple JRE s and path was not pointing to the correct JRE folder to get JVM.dll.
    Problem was all the application installers install JREs and mess up the path variable.
    Once I put the JRE version I need st the top of the path, It worked.
    Make sure your path is pointing correctly to get the JVM.dll
    Otherthing is if you are using MS VStudio 6.0 or .Net version check your INCLUDE libraries are pointed to the correct JRE version.
    If this doesn't help explain further about your problem
    Good luck

  • Hi, I downloaded an app called "futoshiki". I need to get some "how to" information about it. It has a name like "Shinchi Nishimori" associated with it. Can anyone help?

    Hi, I dowloaded an app named "FUTOSHIKI". It has the name "Shinichi Nishimori" associated with it. I need to know what the blocks under the top row of numbers with the X's and check marks are used for?  Thanks,GrandpaS

    Contact the developer
    http://www.9bitlabs.com/support.aspx

  • My grand daughter downloaded a  microsoft app called silverlight and i need to delete in order to use the app netflix!

    how can i delete an microsoft app that was downloaded in error?

    You need to purchase a GPS receiver.  See:
    http://www.amazon.com/s/?ie=UTF8&keywords=gps+for+ipod+touch&tag=googhydr-20&ind ex=aps&hvadid=6032779647&ref=pd_sl_b11rgefsv_e

  • Localize app. using Bundle.properties files, need help

    Hi! I used tutorial to internationalize my app.:
    http://www.oracle.com/technology/products/jdev/101/howtos/jsfinter/index.html
    I use Jdeveloper 11g. Have 2 files: LocalizeKokaugi.properties and LocalizeKokaugi_en.properties. My app is internationalized, but when I need to change language then I need use IE or FireFox settings to set language. I have two questions:
    1. What I need to do to change language using my created buttons? Can You give step by step to this?
    2. Can I set VO -> Attributes -> Control Hints -> Labet Text to #{sampleBundle.myTitle}. I tried this, but then the label value don't comes from my bundle. Where is problem and what to do?
    Waiting response from You!
    Best regards

    Deniz Gulmez wrote:
    Hello,
    Is below method enough to change the locale for Application Module also? I am trying to change the locale using the below code. Messages from UI project changes as expected but Entity labels and error messages from Application Module are still in old locale.
    private void switchToLocale(Locale locale)
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();
    root.setLocale(locale);
    It should... However I must admit that I rarely push the Locale on the model layer, it does not belongs there, even if ADF encourage that pattern, I highly dislike it and do everything in my power to not have it used in my project. Presentation language is, well, a presentation concern, so should be handled in the presentation layer, not the business one. When the model must send an information, it should be using a code and parameters that then get translated by the view.
    Regards,
    ~ Simon

  • Hi guys please I need help basically I was using my ipad and decided to download an app I clicked it and hit install and the circle thing started moving but it just stopped and the app said free please I need help

    Guys I was using my ipad today and I decided to install an app so I started it and the circle came and it stopped and the app again said free
    And my App Store turned Chinese
    And when I tried to make a new Apple ID it gave me a warning you might be connected to a server pretending to be buy.iTunes.com at put your private information at risk
    PLEASE help me!!

    Your friend and whomever they talked to are wrong.  That message occurs when your device is locked to another carrier, and only that carrier can authorize an unlock request.
    Apple does not unlock devices for consumers - they merely process unlock requests submitted by authorized carriers.  Your friend needs to contact his carrier and request an unlock for that phone, assuming the carrier offers unlocking (not all do nor are they required to).
    See Apple's own documentation - http://support.apple.com/kb/ht5014

  • Need to send photos contact etc to ipad. From my Samsung galaxy s ? Ipad will not download Samsung kias to do it via wifi need help ASAP

    Need to send all my info from Samsung galaxy s to my ipad nothing seams to work.

    Your contacts on your Samsung should be synched to your google account so on your iPad go to Settings-->Mai,Contacts, Calendars. Add your google account. As for your photos I would use Dropbox. It's free and can be used across mutiple devices. Download and install Dropbox on your Samsung and then synch your photos to your Dropbox by sharing the photos to Dropbox. I'm not too familiar with the Galaxy tab but it should have a built in photo app with an option to share your photos. What else do you need to transfer over?

  • My Ipod touch 4th generation is not working, its frozen, ive tried everything and its not working, its just frozen on an app and i really really need HELP!!!

    My Ipod is frozen!!! Its a 4th generation and its frozen on an app, Ive tried everything like holding down the lock screen and stuff and its not showing the red thing to slid to shut it down....This is my only thing to use to contact my friends and its not working, i dont have a phone and i cant get one, so this is the onlything i have.....PLEASE HELP!!!

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • E65 Call Divert Error Message - Need Help

    Hello,
    I’ve been trying to divert all voice calls to my voicemail but the phone keeps giving me this message “Invalid Phone Number”.
    My service operator has *555 as voicemail number…
    Any suggestions?
    Thanks again!
    Martin

    Try either fixing permissions or removing the user cache using Onyx or Applejack.

  • Dead screen, transfering documents via firewire - need help

    Greetings,
    So I've got a 1 Ghz iMac (floating pivot screen.) - my primary mission critical workstation. My screen died today. Grrrr.
    No time to muck about, I went out and purchased a mac mini (1.5 Ghz single intel core), I want to transfer all data from the old box to the new asap.
    The migration assistant that appears at first boot up is cool, and I was able to move all applications. (handy!)
    Problem is that I couldn't move all my user documents because the old Mac's drive is 80 gig and the new is only 60. So I figured I would just drag and drop as much as I can manually.
    I've gone and reattached the old mac to the new via firewire and booted up the old box as an external drive. Problem is, when I open up the user folder on the old hard drive I'm not seeing any files.... ie. all folders including the old desktop folder are empty....its like the files are hidden or something.
    Help please.

    could it be because under ownership and permissions I have no access to these folders? Is that why the folders "appear" empty? - then my next question would be, how can I give myself access to them?
    Remembering that I am unable to boot up and use the old iMac (except in external drive mode) since the screen (or video card???) is dead.
    Also - I'm attempting spotlight searches from the new mac on the old mac's HD for known files on the old mac's desktop and its coming back with nothing...
    What a mess ....maybe

Maybe you are looking for

  • PO Ammendment and version number

    Dear Experts, We have version management active at out client. When we save the PO after changes version number is generated and changes are saved against that version number. We want the report where we can see the Ammendment details in the PO , tha

  • How do I use my Email facility

    I am a new Blackberry user and being of advanced years find some of the new technology difficult to understand.  I have now posted 3 questions on this forum and have been delighted with the help I have received. My 4th question is as follows: I have

  • Adapter module configuration

    The message that reaches the file receiver channel is <EDI_DC40>               structure1 </EDI_DC40> <EK1NA1M>               structure 2 </EK1NA1M>              So i wanna write a module configuration which will rename the first tag as <ek1na1m>. Pl

  • Get billing list by customer purchase order

    Hi Experts:                  Is there any standard T-code which can get billing list by customer purchase order ?                 Billing contains delivery-related and order-related,                 one po can has several sales order,and one sales or

  • How can I make one list of all events I have in over 30 libraries I made

    How can I make one list of all events I have in over 30 libraries I made?