Problem with JNI hello world

I found some tutorial on SUN site on how to use JNI. I'm using Eclipse to compije Java and C (via Cygwin) files. Here are complete files:
Hello.java:
class Hello
     public native void sayHello();
     static
          try
          System.loadLibrary("hello");
          catch(Exception e)
               System.out.println("exc");
     public static void main(String[] args)
          Hello h = new Hello();
          h.sayHello ();
}Hello.c:
#include <mingw/_mingw.h> //because there are some types needed for JNI
#include <jni.h>
#include "Hello.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_Hello_sayHello
  (JNIEnv *env, jobject obj)
     printf("Hello world!\n");
     return;
}Makefile:
hello.dll : Hello.o Hello.def
     gcc -g -shared -Wl,--kill-at -o hello.dll Hello.o hello.def
Hello.o : Hello.c Hello.h
     gcc -c -g -I"$(JAVA_HOME)\include" -I"$(JAVA_HOME)\include\win32" Hello.c -o Hello.o
Hello.h : Hello.class
     javah -jni Hello
clean :
     rm Hello.h
     rm Hello.o
     rm hello.dllHello.def
EXPORTS
Java_Hello_sayHelloEverything goes well, but when I run java program it does nothin (it should print message, but it just exit without any error).I'm sure that it's something stupid, but I cant see what. Can anyone tell me what am I doing wrong?
Thenks.

Answer 1: yes, there was no problem. I compiled and started simple 'hello world' program from Cygwin and from WinXP console, and it worked well.
Answer 2: This is weird, I changed code to this:
Hello.java:
     public native int getInt();
          System.out.println("Returned int is " + h.getInt());Hello.c:
JNIEXPORT jint JNICALL Java_Hello_getInt
  (JNIEnv *env, jobject obj)
     return 25;
}It does not print anything. I started this program from Cygwin and from WinXP console, and from Eclipse. Only if I debug in Eclipse (step by step) I get:
Returned int is 25and still I don't get Hello string printed (even if I go step by step). It looks like cygwin has some problem with OS. Do you have any idea what to do, I'm a bit confused?
Thank you.
Message was edited by:
zly

Similar Messages

  • Awkward problems with JNI on J2SE 5.0

    I'm experiencing a strange problem with JNI and I hope someone can help me out.I've installed Cygwin, MinGW and then the CDT plug-in for Eclipse C/C++ development. This means I've used the MinGW make utility. It successfully creates the DLL file, but for some awkward reason, function www_tutorial_jni_HelloWorld_displayHelloWorld cannot be found (UnsatisfiedLinkError: displayHelloWorld).
    The Java class looks like this:
    package www.tutorial.jni;
    public class HelloWorld {
        public native void displayHelloWorld();
        static {
            System.loadLibrary("hello");
        public static final void main(String[] args) {
             try {
                  HelloWorld hw = new HelloWorld();
                  hw.displayHelloWorld();
             } catch (Exception e) {
                  System.out.println(e.toString());
    }The header that was generated by javah.exe (version 1.5.0_01) looks like this:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class www_tutorial_jni_HelloWorld */
    #ifndef _Included_www_tutorial_jni_HelloWorld
    #define _Included_www_tutorial_jni_HelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     www_tutorial_jni_HelloWorld
    * Method:    displayHelloWorld
    * Signature: ()V
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld
      (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endifThe C++ implementation looks like this:
    #include <jni.h>
    #include "www_tutorial_jni_HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld(JNIEnv
    *env, jobject obj)
        printf("Hello world!\n");
        return;
    }I've made sure that the fully qualified name of the implementation function is identical to the one in the header. I don't understand why I still get the error; especially since checking the DLL reveals that a function called "Java_www_tutorial_jni_HelloWorld_displayHelloWorld" exists.
    Could someone try and produce a successfull DLL/SO from the C++ code and then try and run the Java part on a 5.0 version of Java? I'm really curious as to what on Earth is going on...

    ... Otherwise, I would have
    to add whatever directory I put my DLL into to the
    PATH variable.Not necessarily. I believe the "PATH" also implicitly includes the "current directory". I also think that most JNI users put their DLL in a directory from which they also launch java (so it's in the current directory).
    >
    ... a java.library.path set.
    If I don't explicitly set a Java library path,
    Eclipse can't even find the DLL. I'm beginning to
    believe that Eclipse somehow screws up running Java
    programs with native code...I don't know about that... Probably just something extra you have to do with your Eclipse project so that it can find the DLL.
    But like I said, I don't really know - just trying to throw out ideas, small as they may be.

  • Problem with JNI for target armlinux

    Dear friends,
    We have compiled CVM for ARM Linux and it is working fine for java programs as well as C programs.
    But when I try to make shared library out of a sample hello world JNI program for arm linux it says 'jni.h: No such file or directory' and after that many lines 'syntax error' and 'parse error' etc.
    But the same program is running fine on x86 linux. Problem only while cross compiling for arm linux. It is not problem with arm-v5t-le-gcc because that is working fine. Problem is with what I need to include in makefiles.
    As I am new to this domain could anyone help me where I am missing?
    Regards
    Kishore

    I'm not exactly sure what you're talking about, but it sounds like you may need to look into global references. Look at NewGlobalRef() and DeleteGlobalRef() and see if those help you out.
    God bless,
    -Toby Reyelts
    For all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Problem with JNI and Parallel Port dll

    Hi. I'm doing some testes with JNI. Firs i followed the netbeans tutorial for doing a C programa that prints somthing for java.. like.. "Hello java from C".
    So i tried to load a dll from my dll. Like, I have this dll to use the parallel port on windows Xp. So i created a dll to access it an comunicates eoth java.
    I did everything just fine.
    When I start my Java app, the first thing it does is to load this parallel port dll and configure the functions of it.
    After that .. I get this error
    EXCEPTION_FLT_STACK_CHECK (0xc0000092) at pc=0x0093d269, pid=2284, tid=3000
    Can someone explain why ?
    (Sorry if i wasn't clear enough, english is not my native language, so ask if you don't understand something.. )

    hi ,
    I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
    Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
    ==============================
    error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
    2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
    message: Waiting for 2 instance(s) to be deallocated
    ==============================
    cause: the number of connection to database exceeded.another word,too many connections.
    ==============================
    solution: close the connection when it becomes useless for your program. :)
    ==============================
    ps. Sorry for my weak English . hehe ....

  • TO BLACKBERRY-YOU HAVE A PROBLEM WITH BLACKBERRY APP WORLD NOT ACCEPTING CREDIT CARDS

    HI, I AM AN OWNER OF A BLACKBERRY Q10 AND A LOYAL BLACKBERRY USER SINCE THE 8800 SERIES BLACKBERRY CURVES.   THERE IS SOME TYPE OF PROBLEM WITH BLACKBERRY WORLD.  I AM CURRENTLY RUNNING 10.3.2.556.  UNTIL LAST THURSDAY BLACKBERRY APP WORLD WORKED WITH MY CREDIT CARD.  THEN ALL OF A SUDDEN IT JUST STOPPED.  SAYING THAT THERE WAS A PROBLEM WITH THE TRANSACTION AND TO TRY AGAIN LATER.  NOW I CANNOT USE MY CREDIT CARD AT ALL.   I AM POSTING THIS IN MULTIPLE FORUM BECAUSE I AM NOT THE ONLY ONE HAVING THIS ISSUE.  I HAVE RECENTLY POSTED THIS PROBLEM ON CRACKBERRY.COM AND OTHERS ARE HAVING THE SAME PROBLEM.  http://forums.crackberry.com/ask-question-f432/why-blackberry-world-will-not-let-me-purchase-apps-when-working-before-1032609/?mn_qa=1#post11839564 AND IF YOU LOOK ON THIS SITE AND CRACKBERRY FURTHER YOU WILL SEE OTHERS ARE HAVING SIMILAR ISSUES.  I HAVE ALREADY TRIED TO GO ONTO THE BLACKBERRY APP SITE ON MY COMPUTER BUT NOW THERE IS NO OPTION TO CHANGE THE PAYMENT OPTIONS THERE ANY MORE.   WHAT IS THIS.  WHY IS IT HAPPENING??????  CAN YOU PLEASE LOOK INTO THIS PLEASE WHOMEVER FROM BLACKBERRY SEES THIS POST.    SINCE THERE IS NO NUMBER TO CALL FOR HELP ABOUT THIS I AM POSTING HERE UNTIL SOME TYPE OF BLACKBERRY PERSON ANWERS.   I AM ALSO GOING TO TRY AND POST THIS IN THE FORUMS FOR Q10, CLASSIC, PASSPORT, LEAP, ETC., SO SOMEBODY CAN HELP US.  SOME PEOPLE SAY IT HAS BEEN GOING ON FOR MONTHS ON THEIR ACCOUNT AND NOTHING HAS BEEN DONE.  HELP US PLEASE.  THANK YOU.  

    Hello andreabn90
    If you can't remember your security questions go to  Express Lane.
    select iTunes from the list, then iTunes store.        On the next screen select account Management.          There, select iTunes store account security and write that you would like to reset your security questions and / or answers.
    You should get an eMail reply over the next 24 hours.

  • Problem with JNI

    i have to implement a few standard APIs. As a part of the implementation I have to provide references to an object I create. Now my underlying code is C++ with JNI used to throw the Java APIs. Problem is JNI now returns different references for the same object and hence my prupose id defeated. Could anyone suggest how this problem can be overcome.

    I tried to figure out what your problem is, but can't. Please rephrase it and give a bit more detail on what you are doing and what is going wrong.

  • Problem with jni references

    i have to implement a few standard APIs. As a part of the implementation I have to provide references to an object I create. Now my underlying code is C++ with JNI used to throw the Java APIs. Problem is JNI now returns different references for the same object and hence my prupose id defeated. Could anyone suggest how this problem can be overcome.

    I'm not exactly sure what you're talking about, but it sounds like you may need to look into global references. Look at NewGlobalRef() and DeleteGlobalRef() and see if those help you out.
    God bless,
    -Toby Reyelts
    For all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Problem with JNI form C++

    Hi all,
    I'm fairly new to programming with JNI, so please excuse me if I ask a dumb question.
    I'm trying to call a Java method from a C++ class, but when I run the program, it throws an error, crashing the program. I'm pretty sure the problem is that the call to env->getMethodID() is throwing an error. I have looked around to try and find a way call a function with no arguments, but all of the examples that I have found all call a Java main.
    I'll post my code and the error message below so that things are a bit clearer.
    Thanks,
    Robert.
    Here is the main.cpp. This is where the program is started.
    #include "/usr/lib/jvm/java-6-sun-1.6.0.06/include/jni.h"
    int main()
       JNIEnv *env;
       JavaVM *jvm;
       jint res;
       jclass cls;
       jmethodID mid;
       // creation of the JVM
       JavaVMInitArgs vm_args;
       JavaVMOption options[1];
       options[0].optionString = "-Djava.class.path= .";
       vm_args.version = 0x00010002;
       vm_args.options = options;
       vm_args.nOptions = 1;
       vm_args.ignoreUnrecognized = JNI_TRUE;
       res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
       // now the rest of the code can work
       cls = env->FindClass("Test");
       mid = env->GetMethodID(cls, "run", "()V");
       env->CallVoidMethod(cls, mid);
       jvm->DestroyJavaVM();
    }Here is Test.java
    public class Test
       public void run()
          System.out.println("stuff");
          foo();
       public void foo()
          System.out.println("asdfasdf");
    }And here is the error message.
    # An unexpected error has been detected by Java Runtime Environment:
    #  SIGSEGV (0xb) at pc=0x06245f7d, pid=9054, tid=1076641792
    # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing linux-x86)
    # Problematic frame:
    # V  [libjvm.so+0x245f7d]
    # An error report file with more information is saved as:
    # /media/MY STICK/jni/cpp/hs_err_pid9054.log
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    AbortedEdited by: metaldrummer610 on Apr 23, 2008 8:35 PM

    Yeah, so I just figured out what was wrong. I wasn't calling main from in Java. My bad guys.

  • Disconnection problems with online gaming - world ...

    Other users on BT have alos reoported issues with game hangs and diconnection issues with World of Tanks.
    They seem to have started a few days ago. Someitme it is intermittant other times it can last for several minutes.

    Having the same issue since yesterday 6th September 2012.
    World of Tank client keeps disconecting, then has issues logging back in to the client.
    This seems to be hapening to a lot of other players in the UK all on BT
    http://forum.worldoftanks.eu/index.php?/topic/149124-lag-and-disconnection/
    BT had the same problem with World of Warcraft recently, something to do with a BT peering issue. I can only hope this problem is sorted soon.
    No other internet activity is affected.

  • Problems with download BB world

    Dear,
    I got problems with Blackberry bold. BB world.
    This app need upgrade. When I accept it, it send me direct to BB pages for download, but nothing happend.
    On page is mentioned times run out.
    Could you help me please?
    Stepan
    Solved!
    Go to Solution.

    Hi and Welcome to the Community!!
    Please try this sequence:
    1) Remove AppWorld from your BB
    KB10040 How to view or remove installed applications on a BlackBerry smartphone
    If it requests that you reboot the BB, do so
    2) Do a Batt-Pull reboot (power on, remove battery, wait, insert battery, wait), even if redundant to the one you did in step 1.
    3) Install (on your BB) a fresh copy of AppWorld
    http://blackberry.com/appworld/download
    Again, if it requests to reboot, do so.
    4) Do another Batt-Pull reboot
    5) See if it now works.
    Cheers!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • IPhone SDK 3.1: Problem compiling first Hello World App

    Hi,
    I am new to XCode, Mac OS and iPhone Development.
    I had already installed the earlier iPhone SDK (version prior to the latest 3.1) into my Mac OS 10.6. I was not able to run
    the hello world program through xCode as while opting for Build and Run, the simulator it was giving me an error saying that it cannot find the right SDK.
    I had assumed that the old SDK is not compatible with the new Mac OS 10.6 (Snow Leopard). I had then uninstalled the old
    iPhone SDK using Terminal tool, using the command line given in the xCode uninstall guide.
    Installed the latest iPhone SDK (version 3.1), and then tried to compile the hello world app through xCode. Now I am getting the following error:
    *error: can't exec '/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2' (No such file or directory*)
    I had located the above mentioned directory and could not find the file: "gcc-4.2" as mentioned in the error. Instead
    executable files like "i686-apple-darwin10-gcc-4.2.1" are present there.
    My Project Settings are:
    Project Format - xcode 3.2 -compatible
    Base SDK - iPhone Simulator 3.1
    Compiler Version - System Default (GCC 4.2)
    I am totally confused here, as I don't know how to correctly set up the ENV, as I thought the iPhone installer SDK does that automatically.
    Please help me out.
    Thanks in advance for your time,
    JC.
    Error Messages:
    Build helloworldxc of project helloworldxc with configuration Debug
    ProcessPCH /var/folders/P-/P-zMg0EzHree36VYyqKEvU+TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/helloworldxcPrefix-gylsydenhucpkgfnujlgvzvhfhzd/helloworldxcPrefix.pch.gch helloworldxc_Prefix.pch normal i386 objective-c com.apple.compilers.gcc.4_2
    cd "/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc"
    setenv LANG en_US.US-ASCII
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -D_IPHONE_OS_VERSION_MINREQUIRED=30000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1 .sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/Deb ug-iphonesimulator/helloworldxc.build/helloworldxc-generated-files.hmap -I/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/D ebug-iphonesimulator/helloworldxc.build/helloworldxc-own-target-headers.hmap -I/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/D ebug-iphonesimulator/helloworldxc.build/helloworldxc-all-target-headers.hmap -iquote /Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/Deb ug-iphonesimulator/helloworldxc.build/helloworldxc-project-headers.hmap -F/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/Debug-iphonesimulato r -I/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/Debug-iphonesimulato r/include -I/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/D ebug-iphonesimulator/helloworldxc.build/DerivedSources/i386 -I/Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/build/helloworldxc.build/D ebug-iphonesimulator/helloworldxc.build/DerivedSources -c /Users/jaideepchakravorty/Jaideep/R&D/helloworldxc/helloworldxc_Prefix.pch -o /var/folders/P-/P-zMg0EzHree36VYyqKEvU+TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/helloworldxcPrefix-gylsydenhucpkgfnujlgvzvhfhzd/helloworldxcPrefix.pch.gch
    while compiling hellowworldxc_Prefix.pch,
    error: can't exec '/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2' (No such file or directory)

    Could you let me know as where is the xcode setting through which it is looking for the compiler in the following path ? This path is probably wrong (Pls refer to the error messages)
    I'm not sure this will be of any help to you -- I'm not sure if it's the answer you're looking for, since I don't really know enough on the subject. However, this may answer your question, or at least maybe help you find the answer for yourself, so it's worth a shot. Try going to Edit Project Settings in the Project menu, and once the Project Settings open, select the Build tab. Search through this and see if you find any preferences along the lines of what you are looking for. In particular I would try the sections toward the bottom about the GCC 4.0 compiler. Sorry if this was a waste of time, but I wanted to try...

  • Problem with JNI and Tomcat (and threads???)

    Howdy,
    Here is the issue - I would like some help on HOW to debug and fix this problem:
    2 test use cases -
    1)
    a)User goes to Login.jsp, enters user and password
    b) User submits to LoginServlet
    c) login calls JNI code that connects to a powerbuilder(Yes I know this is ugly) PBNI code module (this is a .dll) that authenticates the user with the database
    d) the servlet then redirects to another .jsp page
    e) user then submits to LogoutServlet - also a JNI call to a powerbuilder PBNI code module
    f) REPEAT STEPS a-e over a few times (inconsistent) and then the call to the JNI code hangs
    2)
    a) users does NOT goto Login.jsp, but rather calls LoginServlet and passes the userid and password as GET parms
    b) user does NOT get redirected to a page (redirect code commented out)
    c) user calls LogoutServlet
    d) repeat steps a-c at will and no failure, no hanging
    The only difference is that in case 1 (with JSP), there is a redirect and it afffected the JNI call by haniging inside JNI code.
    In case 2 (without JSP) there is still a JNI call, but it does not hang. In addition, when it hangs and I stop Tomcat, the logs show cleanup entries that say:
    Oct 19, 2004 9:17:09 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Oct 19, 2004 9:17:10 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Oct 19, 2004 9:17:11 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Is this a threading issue in Tomcat???
    On would assume that the JNI code is not cleaning up after itself, but I don't believe this is the case,
    and even if it was, why would I get the tomcat log cleanup entries above???
    What do those cleanup entries imply about the state of Tomcat????

    hi ,
    I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
    Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
    ==============================
    error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
    2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
    message: Waiting for 2 instance(s) to be deallocated
    ==============================
    cause: the number of connection to database exceeded.another word,too many connections.
    ==============================
    solution: close the connection when it becomes useless for your program. :)
    ==============================
    ps. Sorry for my weak English . hehe ....

  • Problem with JNI and Tomcat in windows

    Hello guys...
    I have the following problem.
    I used Tomcat 4 and I have following ApiEncriptacion class, in package com.servipag.sts;
    package com.servipag.sts;
    class ApiEncriptacion
         public native String encripta(String texto, String ubicacionLlavePublica, String semilla);
         static
              System.loadLibrary("apisdark");
         public native String desencripta(String texto, String ubicacionLlavePrivada);
         static
              System.loadLibrary("apisdark");
    the LD_LIBRARY_PATH is set in following dir c:\tomcat\bice
    the dll this in the following path = c:\tomcat\bice\apisdark.dll
    I run Tomcat at the following way..
    C:\jdk1.4\bin\java.exe -jar -Djava.library.path="c:\tomcat\bice" -Duser.dir="C:\Tomcat" "C:\Tomcat\bin\bootstrap.jar" start
    but, still appear the error:
    java.lang.UnsatisfiedLinkError: encripta
         at com.servipag.sts.ApiEncriptacion.encripta(Native Method)
         at com.servipag.sts.ServiciosServiPagImpl.rescatarFirma(ServiciosServiPagImpl.java:2143)
         at com.servipag.sts.ServiciosServiPagImpl.pagarCuenta(ServiciosServiPagImpl.java:310)
         at org.apache.jsp.SBCO_0005flogin_0005fbice_0005f4$jsp._jspService(SBCO_0005flogin_0005fbice_0005f4$jsp.java:265)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
         at java.lang.Thread.run(Thread.java:536)
    please help me
    Luis Navarro.
    Chile

    ApiEncripatcion.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ApiEncriptacion */
    #ifndef IncludedApiEncriptacion
    #define IncludedApiEncriptacion
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: ApiEncriptacion
    * Method: encripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_encripta
    (JNIEnv *, jobject, jstring, jstring, jstring);
    * Class: ApiEncriptacion
    * Method: desencripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_desencripta
    (JNIEnv *, jobject, jstring, jstring);
    #ifdef __cplusplus
    #endif
    #endif
    ApiEncriptacion.c
    #include "jni.h"
    #include <stdio.h>
    #include "files.h"
    #include "hex.h"
    #include "rsa.h"
    #include "randpool.h"
    USING_NAMESPACE(CryptoPP)
    USING_NAMESPACE(std)
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed);
    char RSAEncryptString(const char pubFilename, const char seed, const char message);
    char RSADecryptString(const char privFilename, const char *ciphertext);
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_encripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePublica, jstring semilla)
         try
              char *ciphertext = RSAEncryptString(ubicacionLlavePublica, semilla, texto);
              delete [] ciphertext;
              return(ciphertext);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_desencripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePrivada)
         try
              char *decrypted = RSADecryptString(ubicacionLlavePrivada, texto);
              return(decrypted);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    int main()
         return(0);     
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         priv.DEREncode(privFile);
         privFile.MessageEnd();
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
         pub.DEREncode(pubFile);
         pubFile.MessageEnd();
    char RSAEncryptString(const char pubFilename, const char seed, const char message)
         FileSource pubFile(pubFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Encryptor pub(pubFile);
         if (strlen(message) > pub.MaxPlainTextLength())
              cerr << "message too long for this key\n";
              abort();
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         char outstr = new char[2pub.CipherTextLength()+1];
         pub.Encrypt(randPool, (byte *)message, strlen(message), (byte *)outstr);
         HexEncoder hexEncoder;
         hexEncoder.Put((byte *)outstr, pub.CipherTextLength());
         hexEncoder.MessageEnd();
         hexEncoder.Get((byte *)outstr, 2*pub.CipherTextLength());
         outstr[2*pub.CipherTextLength()] = 0;
         return outstr;
    char RSADecryptString(const char privFilename, const char *ciphertext)
         FileSource privFile(privFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Decryptor priv(privFile);
         HexDecoder hexDecoder;
         hexDecoder.Put((byte *)ciphertext, strlen(ciphertext));
         hexDecoder.MessageEnd();
         SecByteBlock buf(priv.CipherTextLength());
         hexDecoder.Get(buf, priv.CipherTextLength());
         char *outstr = new char[priv.MaxPlainTextLength()+1];
         unsigned messageLength = priv.Decrypt(buf, (byte *)outstr);
         outstr[messageLength] = 0;
         return outstr;

  • Problem with Jni on Solaris

    Hello I am using a Native code that is working perfect on Windows .
    I have used DllMain calls to initialize my threads .
    I attach my lower stack threads to the JNI by using these methods.
    Well I want to know what is way to put the same functionality on Solaris.As this particular method is specific to Windows Platform only.
    BOOL APIENTRY DllMain( HANDLE hModule,                     // handle to DLL module
    DWORD ul_reason_for_call,      // reason for calling function
    LPVOID lpReserved                // reserved
         BOOL returnValue = FALSE;
    switch (ul_reason_for_call)
              case DLL_PROCESS_ATTACH:
                   // We do not perform any initialization
                   // within this section. Instead we have
                   // chosen to use the JNI_OnLoad function
                   // as the library initialization point.
                   returnValue = TRUE;
                   break;
              case DLL_THREAD_ATTACH:
                   // We are to initialize the thread local storage
                   // variables in this call.
                   if( BridgeUtility::getInstance() -> threadInitialize() != 0 ) {
                        returnValue = FALSE;
                        printf(" Thread initialize failed..\n");
                   }else {
                        printf(" Thread initialize succed..\n");
                        returnValue = TRUE;
                   break;
              case DLL_THREAD_DETACH:
                   // We are to uninitialize the thread local storage
                   // variables in this call.
                   if( BridgeUtility::getInstance() -> threadUninitialize() != 0 )
                        returnValue = FALSE;
                   else
                        returnValue = TRUE;
                   break;
              case DLL_PROCESS_DETACH:
                   // We do not perform any uninitialization
                   // within this section. Instead we have
                   // chosen to use the JNI_OnUnload function
                   // as the library initialization point.
                   returnValue = TRUE;
                   break;

    If your aim is to load the library and initialize it
    that one time, consider using the pthread once routines
    to handle library initialization. See, for example,
    chapter 5 of Butenhof's "Programming with POSIX
    threads".

  • Problem with JNI on netBeans

    Hi !
    After a search on the forum, I request your help about a little JNI app developped to work with a 3D sensor. The research team in which I work use to working with Eclipse IDE, and this JNI appliation work on it. However, impossible to find a way on NetBeans... I get an exception :
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    materiel.videoproj.JNIsiapp.SiInitialize()I
    at materiel.videoproj.JNIsiapp.SiInitialize(Native Method)
    at materiel.videoproj.JNIsiapp.main(JNIsiapp.java:138)
    It seems the IDE get the DLL (if I change the name in the loadLibrary method, the exception change) but encounter an error with the native method.
    The application (source code + dll + java code) could be find on ftp :
    ftp://ftp-us.3dconnexion.com
    login: jni
    password: dev1221
    Please help me too find a way !
    FloDeTours

    Library loading seems to continue to be a problem. There are two things to consider. First if you wrote the C/C++ code (like in the tutorials) then you compile it into a dll. This is the only dll you have to worry about. It will get loaded by your Java code using loadLibrary.
    This method is going to look for the dll on the path java.library.path. If you don't set this, it is equal to the system path. I like to keep everything inside my project so I put alll dlls in a directory off my project root called "native". So I set java.library.path to "native". In any case it should point to the location of the dll if it is not on the system path.
    Second if you have a 3rd party dll then you also have a JNI dll. The JNI dll is the one that loadLibrary loads, so the above applies to it. The third party dll is loaded on the C/C++ side, which know nothing about java.library.path. I only knows system path. This means that the location of this dll must be in that path. You can add the location to the system path permanently or use the IDE project setting to add it only inside the project scope.
    When you deploy the app you will need to supply the various path settings in the launching code.
    Jim

Maybe you are looking for

  • Windows 2008 R2 DHCP scope change - Netsh Exec not working

    OK, there seems to be a disconnect between Netsh documentation and how it actually works.  We are in the process of re-addressing ALL our DHCP scopes (joys of a buy-out) and using the steps outlined in numerous MS articles and Blogs etc... we should

  • New 2010 Mac Mini and LG 37" Full HD (via HDMI) query..

    Hello all! I have just bought the new Mac Mini which I want to use along with my LG 37" (LH5000) full HD LCD TV.I have hooked them both up together via HDMI. When I first turned the Mac Mini on it detected various resolutions and choose 1080p. Howeve

  • OSX Server / MAMP / Move material from client to server

    I have a several questions. On my laptop I've been using MAMP (mamp.info) for quite some time, and I love it, most notably for the ease of use and clear directory structure. I've recently purchased a mini and osx server to learn that environment, and

  • Implement the web-service API on an external service desk

    Hi, I want to implement the web-service API on an external service desk system. I am working with the IMG and got to the point where I define a logical port. At this point I need the web-service to be implemented on the external system. I have web-se

  • Offline applications for balckberry

    Hi Can the offline apps be developed for blackberry.As MI Client can process requests and produce the HTML for HTTP requets through PDA's or Desktop browsers.Will the MI Client(in offline mode) on blacberry be able to run an application.. as such WAP