Can i calling C code via JNI?-----a static library(libxxtc.a)

failed always:(
JNI don't surport the static library ?
such as libxxtc.a
please help me!
thanks!!!

Start here: http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
But in general, there's no reason you can't link a static library into a JNI-based program.
Or if you want to "load" a static library into a JVM process the same way you can load a JNI-based shared library, then the answer is no, static libraries don't work that way, they have to be linked into something else.
-slj-

Similar Messages

  • How to get exit code from C code when calling java method via JNI?

    Hi, All
    in my project, i need to call a java method from C code using JNI, yet I do
    not know how to
    retrieve the exit code of java program. the java code is like below
    public static void main(....)
    if(error){
    System.exit(-77);// the exit code is -77
    and the JNI c code may like below
    /* Invoke main method. */
        (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
    //here I want to retrieve the exit code from java to check if there is an
    error
    any suggestions? thanks

    Hi Liang Zhang,
    In your C code add:
    void (JNICALL y_exit)(jint code) {
    and when you are initialazing JVM options add:
    JavaVMOption options[...];
    options[...].optionString = "exit";
    options[...].extraInfo    = y_exit;
    See http://java.sun.com/j2se/1.3/docs/guide/jni/jni-12.html
    Best regards, Maksim Rashchynski.

  • How can I call a function via two different eventListener, is it possible?

    Hi...
    I want to call one function two different way... I write following code, but an error appears..
    Could you help me.. ?
    Thanks...!
    /******************************** LET'S CALL VIA TWO DIFFERENT EVENTLISTENER A FUNCTION ***********************************************/
    var trigger:Timer = new Timer(1000, 10);
    function showAll(evt:TimerEvent, olay:MouseEvent):void{
    /* code blocks */
    increase_btn.addEventListener(MouseEvent.CLICK, showAll);
    trigger.addEventListener(TimerEvent.TIMER, showAll);
    trigger.start();
    Gürkan Şahin
    Code Developer/Coder
    Turkey

    var trigger:Timer = new Timer(1000, 10);
    function showAll(evt:*):void{
    /* code blocks */
    increase_btn.addEventListener(MouseEvent.CLICK, showAll);
    trigger.addEventListener(TimerEvent.TIMER, showAll);
    trigger.start();
    Just change the showAll as shown - * is a wildcard - any object/event will work.
    You can also do like:
    function showAll(evt:* = null):void{
    By putting the = null you can call it with the events or just call it like showAll(); if you need.

  • Can you call external code from XE?

    Hi,
    I have an application that uses external code, called via extproc. During a standard Oracle installation, I need to modify the listener configuration to allow it to do so. This is done by modifying listener.ora like follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora10_2)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ANY")
    without the 'ENVS' entry, the listener security prohibits the loading of our code.
    The touble I have on XE is that attempting to restart the listener after this change gives an error:
    TNS-01155: Incorrectly specified SID_LIST_LISTENER parameter in LISTENER.ORA
    NL-00303: syntax error in NV string
    Does this mean that external code cannot be used? or does anyone know a workaround?
    Thanks in advance,
    Jim

    One obvious problem is the missing close paren, seen when you reformat as follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora10_2)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ANY")
    ) <--- this is missing

  • How can I run C++ code through JNI?

    in the Java tutorial "Lesson: Writing a Java Program with Native Methods ", (see "http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html") every thing works fine if I follow all the instruction. but if I change the Native Method Implementation file from:
    #include <jni.h>
    #include "HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
    printf("Hello world!\n");
    return;
    to:
    #include <jni.h>
    #include "HelloWorld.h"
    #include <iostream.h>
    JNIEXPORT void JNICALL
    Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
    cout <<"Hello world!\n";
    return;
    Although ia have a right LD_LIBRARY_PATH setting, I get a error msg after running:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no hello in java.library.path
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.<init>(Throwable.java:94)
    at java.lang.Error.<init>(Error.java:50)
    at java.lang.LinkageError.<init>(LinkageError.java:43)
    at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
    at java.lang.ClassLoader.loadLibrary(Compiled Code)
    at java.lang.Runtime.loadLibrary0(Runtime.java:470)
    at java.lang.System.loadLibrary(System.java:778)
    at <Unloaded Method>
    Any help will be appreciated.

    From the exception message you submitted here i guess that you might try to load dll of name hello then problem is unable to find the dll refered by you.
    Workaround:
    Place the dll under same directory from where your program is excuted. Otherwise include the dll path to classpath this i'm not sure i have to test it.
    Hope it might help you some extent.
    regards
    jayp

  • Can we call Plain JAVA Code online via MDM Cient

    Hi SDNers,
    For some validation purpose i need to write a JAVA Code(Some body told me that it can be possible i.e we can Java Code for doing Validation)
    i have two Questions.
    1. Can we call JAVA Code online via MDM Client.
    2. where i have to write this JAVA Code and what will be steps of writing this Code.
    Thanx in Advance.

    Hi Tanveer,
    Thanx a lot for ur prompt reply
    Pls reply my this Question also promptly i will be highly thankful for it.
    Q.
      My Requirment is i have to do the validation
      "on the basis of acct grp i have to put validation
          a. the G/L acct must be in particular range.
          b. it must have specific length"
    My sr. developer is saying simply putting the IF ELSE condition in the validation Editor technique 'ld be hard to maintain at later stage as we large number of Acct Grps.
      He is saying look for some Custom function for it
    "SO TELL ME CLEARLY THAT
                                                   --CAN I USE JAVA API FOR THIS
                                                   --AS A EXP. MDM CONSULTANT WILL U
                                                      RECOMMEND IT?
                                                   --IF YES
                                                     THEN
                                                          WHAT 'LD BE EXACT STEPS.
                                                 ---IF NO
                                                    THEN
                                                         WHAT ARE THE OTHERS WAYS
                                                         i.e
                                                         IF U R FACING THIS PROBLEM THEN WAT
                                                         SOLN U R GOING TO USE?
    PLS
    REPLY ASAP as per the exact question(i.e all parts of Q)
    i will highly thank for u.
    Regards
    kuldeep

  • Canot call Weblogic Bean from Delphi via JNI

    I tried to call a bean within the weblogiv server 7 from Delphi.
    I use a JNI Wrapper which allows me easily to acces normal java objects.
    I can call the bean from a java application.
    When i try to call the bean via jni, the following error occurs:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
    [ Assertion violated] at weblogic.utils.Debug.assertion(Debug.java:74)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:258)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:233)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.computeInterfaces(ClientRuntimeDescriptor.java:224)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.intern(ClientRuntimeDescriptor.java:123)
    at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:165)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:145)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.init(InitialContext.java:218)
    at javax.naming.InitialContext.<init>(InitialContext.java:194)
    at ejbtest3.ejbtest3sbTestClient1.getInitialContext(ejbtest3sbTestClient1.java:104)
    at ejbtest3.ejbtest3sbTestClient1.init(ejbtest3sbTestClient1.java:32)
    at ejbtest3.ejbtest3sbTestClient1.testmain(ejbtest3sbTestClient1.java:277)
    It seems that i canno create a context object, but i do not know why ...
    So i would be glad if anyone could help me here ...
    Regards Robert

    I would try this with the newest service pack since it seems this assertion does
    not exist in later code lines. It appears to be related to a class loader
    issue. Do you know what version of the Java VM Delphi uses?
    Sam
    robert wrote:
    I tried to call a bean within the weblogiv server 7 from Delphi.
    I use a JNI Wrapper which allows me easily to acces normal java objects.
    I can call the bean from a java application.
    When i try to call the bean via jni, the following error occurs:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
    [ Assertion violated] at weblogic.utils.Debug.assertion(Debug.java:74)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:258)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:233)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.computeInterfaces(ClientRuntimeDescriptor.java:224)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.intern(ClientRuntimeDescriptor.java:123)
    at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:165)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:145)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.init(InitialContext.java:218)
    at javax.naming.InitialContext.<init>(InitialContext.java:194)
    at ejbtest3.ejbtest3sbTestClient1.getInitialContext(ejbtest3sbTestClient1.java:104)
    at ejbtest3.ejbtest3sbTestClient1.init(ejbtest3sbTestClient1.java:32)
    at ejbtest3.ejbtest3sbTestClient1.testmain(ejbtest3sbTestClient1.java:277)
    It seems that i canno create a context object, but i do not know why ...
    So i would be glad if anyone could help me here ...
    Regards Robert

  • Accessing VB Code using JNI

    Can access functions implemented in Visual Basic from a Java program using JNI?
    I was thinking like, since there's no .h file concept in VB, we can't access VB code from Java. Correct me if i am wrong....
    Thanks,
    Vasu

    As long as the VB app somehow exports its functions via the standard "C" interface (which is how all DLLs are exported), then you can call into it via JNI. I've successfully used JNI to call into a Delphi DLL, for example.
    The hard part is that VB doesn't want to do this by default, and to be honest, I'm not enough of a VB expert to tell you how you could do this. You can check your success, however, by running the dumpbin.exe utility (comes with MSVC) on the compiled DLL and see if your method shows up in some form. Once you know that name and how the parameters look (by-ref or by-val), you should be in good shape.
    I won't say it's an easy road to go, however--you may have more luck just hosting the VB code as an ActiveX control and connecting to it via the higher-level Java->COM APIs. Stu Halloway has a collection of such links on his home page: http://staff.develop.com/halloway.

  • DLL crashes / gives no response via JNI

    I hope anyone can help me with this...
    We have a java test client which calls DLL A via JNI (testpath 1).
    We also have a native test client that calls DLL A directly (testpath 2).
    DLL A calls DLL B, and DLL B calls DLL C.
    Now, according to the debugging, the method call and input parameters ultimately received by DLL C are
    the same (and correct) in both test paths. Now the following occurs: with testpath 2, the reply
    from DLL C is correct, but with testpath 1, DLL C gives no reply whatsoever!
    Could this have something to do with jvm regional settings? Obviously, something in testpath 1
    differs from testpath 2, but I have no idea what this could be...
    Some comments: DLL C uses a lot of global variables and global initializers. Maybe the problem
    is in that area?

    We solved it. Turns out DLL A reserved too much space on the stack. Putting a testclient before
    DLL A left just not enough room on the stack for DLL C to work with.

  • PDA: How does the VI in the "Calling External Code (Inline C Method)" example link to the called functions?

    The PDA module provides an example of calling external code via an inline C
    The inline source code from the example:
         OSVERSIONINFO info;
         info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
         Err = GetVersionEx(&info);
         MajorVersion = info.dwMajorversion;
         MinorVersion = info.dwMinorversion;
    The PDA build specification includes *no* additional source files of any kind.  The only source file in the build is the top-level VI.  Where are the definitions for the OSVERSIONINFO type, and the GetVersionEx function drawn from?
    The VI builds and runs fine on the PDA, but I don't understand how.

    Donovan B wrote:
    Hi Dan,
    It looks like there is an OSVERSIONINFO struct and GetVersionEx function available in the coredll.lib for the application to call on a PDA running Windows Mobile 5.0.  On both operating systems, it looks like the GetVersionEx function is defined in winbase.h, so I am not sure if there is some kind of linking between the two or if the header file is automatically included when building the executable or not.  Let me do some more research and I'll let you know.
    The information for the function on Windows Mobile can be found here.
    Message Edited by Donovan B on 12-19-2007 06:33 PM
    While the API functions are mostly the same for Windows Mobile and normal Windows the actual implementation and compilation is obviously not and there is no need for that. Windwos Mobile is typically (not sure if there are other versions at all) ARM based, while the desktop version is x86 based. A huge difference.
    And when LabVIEW creates a PDA executable it mostly creates a bunch of hidden C files, invokes the Visual C for Windows CE
    tool chain and lets it create the executable. The Visual C for Windows CE tool chain comes with its own import link libraries for accessing WinAPI functions and those import link libraries reference the functions in the DLLs as they are implemented for Windows Mobile (CE). There is no kernel32.dll in Windows Mobile and why should it? You can't move normal Windows code that would expect that DLL to Windows Mobile anyhow, since it has a completely different CPU and there is always a complete recompile with the Windows CE toolchain necessary anyhow.
    Rolf Kalbermatter   
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Reg calling Transaction code in Webdynpro ABAP

    Hi All,
    Can I call Transaction code in Webdynpro ABAP Portal Application. If so, how can this be possible? Can anybody give me a lead?
    Thanks.
    Kumar Saurav.

    Hi,
    The most easy Way is here:
    1) Test any Webdynpro Application from SE80 when the webdynpro Browser opens to display output
    Copy its HTTP link, Suppose we get the below link
    http://r3d01web1.Siemens.dk:8001/sap/bc/webdynpro/sap/z_dynamic_view?sap-client=002&sap-language=EN
    2) Now replace some part of the above link ( webdynpro/sap/z_dynamic_view?sap-client=002&sap-language=EN )  with the new link part ( gui/sap/its/webgui?~transaction=PA30 )
    So that the newly generated link is such that the below one:
    http://r3d01web1.Siemens.dk:8001/sap/bc/gui/sap/its/webgui?~transaction=PA30
    Note in place of PA30 you can put any of your desired tcode.
    3) Now Just Make a webdynpro component and in its View layout put a LINK TO URL ui element
    and in its property REFERENCE just past the http link ( http://r3d01web1.Siemens.dk:8001/sap/bc/gui/sap/its/webgui?~transaction=PA30 )
    4) Activate and test your webdynpro Application.

  • Calling other application via forms

    Hi
    Can we call java applications via oracle forms 6i.
    Thanks in advance

    Have you looked at this white paper?
    http://www.oracle.com/technology/products/forms/pdf/269054.pdf
    Maybe it can help

  • Call COM Components using JNI

    Hi,
    Can we call COM Components using JNI? If yes can someone pls guide me how to go about it
    Thanks
    Guriqbal

    JNIWrapper 2.0 Beta with Java-COM integration is already available for download and evaluation. Check the http://www.jniwrapper.com/news.jsp
    Hope this helps.
    EToporov

  • Calling Java from Delphi via JNI

    Hi all. I've got a J2EE application, and I'm trying to write a Delphi client for the server. More specifics:
    Server and test client running in Win2000 SP4.
    Server running in JBoss (JUnit test cases have successfully connected to the server)
    JDK 1.4
    I'm using some Delphi files from JEDI which allow me to load/access a JVM via JNI. So far, I've been able to:
    1) Create a Properties object.
    2) Populate the Properties object with String values (making sure to use NewStringUTF to pass into the Properties method
    3) Find my java client classes which facilitate opening a connection.
    However, when I attempt to call the method on the object which actually creates the connection, I get an Exception.
    My immediate question is how do I see what the Exception is? I have an Exception object, but ExceptionDescribe doesn't product anything, and I'm having trouble finding any details about the Exception (what type of exception, what the Message or Call Stack is). At the moment, something's wrong but I can't see what. And I'll have no chance of fixing it if I don't know what the problem is.
    Thanks for any help,
    Ed

    I use some code for solving this task (in real project with Delphi 6.0 & Java 1.4.1).
    May be, it will help.
    procedure TJavaInterp.CheckJNIException(Message : string);
    begin
    if JNI_ExceptionCheck(JNIEnv) = JNI_TRUE then
    begin
    JNI_ExceptionDescribe(JNIEnv);
    JNI_ExceptionClear(JNIEnv);
    raise Exception.Create(Message);
    end;
    end;{ TJavaInterp.CheckJNIException }
    procedure TJavaInterp.HandleException(excpt : jthrowable);
    var
    Msg: string;
    ESyntax : Exception;
    CauseName : WideString;
    Tag : OleVariant;
    begin
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsCommonSyntaxError) = JNI_TRUE then
    begin
    ESyntax := Self.BuildSyntaxException(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise ESyntax;
    end;
    Msg := Self.GetMessage(excpt);
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsNPScriptRuntimeException) = JNI_TRUE then
    begin
    CauseName := Self.GetCauseName(excpt);
    Tag := Self.GetTag(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise NPScriptHelper.BuildNPScriptRuntimeException(Msg, CauseName, Tag);
    end;
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsHaltException) = JNI_TRUE then
    begin
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise Exception.Create(Msg);
    end;
    Msg := Self.ToString(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise Exception.Create(Msg);
    end;{ TJavaInterp.HandleException }

  • How to call back to C via JNI in Java started from C?

    Hi!
    This problem might seem outlandish, but I have not been able to find any other method to reach my goal. The situation is the following.
    There is a C++ program I intend to interface with a piece of Java code, called the manager. The C++ code invokes a VM, starts a Java glue code, that connects to the manager via RMI. This works fine. The glue code, however, can be called from the manager, via RMI as well. The problem is, that these calls should in turn call functions in the C++ code, that originally started the Java glue code. JNI can only load a library, but this is not what I want to do now. I want to somehow connect back to the C code that started the Java code. Is this possible at all?
    Thanks for your help,
    Ambrus

    What you want to do is not too tough, but there will be some details to be worked through. In particular, you have to figure out how to make your "callback" get from your "glue" code back into your C++.
    1. Calling back out is from java to C is pretty easy. There is a JNI function for registering a native method with the JVM. Here is an example of the registration code:
    // See if the service interface class is known.
    javaClass = javaEnv->FindClass("JavaInterfaceObject");
    if (javaClass != 0) {
    //Register a native method to place java server messages in the service log.
    // Define the service logger native method.
    JNINativeMethod methods[] = {
    {"addToMessageLog", "(Ljava/lang/String;)V", Java_addToMessageLog}
    // Register the method with the jvm.
    javaEnv->RegisterNatives(javaClass, methods, 1);
         javaEnv->ExceptionClear();     // Just in case not found.
         return TRUE;
    2. You have to define the native method:
    * Native method - callback to place java server messages in the service log.
    JNIEXPORT void JNICALL Server::Java_addToMessageLog(JNIEnv * javaEnv, jclass javaClass, jstring javaMsg) {
         jboolean     isCopy;
         const char* msg = javaEnv->GetStringUTFChars(javaMsg, &isCopy);
         Server::theServer->logger->addToMessageLog((char*)msg);
         if (isCopy)
              javaEnv->ReleaseStringUTFChars(javaMsg, msg);
    3. The real headache is that this is C code, not C++. In other words, if you really need to call into C++, then you need to seed your callback so that it has a pointer to the appropriate C++ object.

Maybe you are looking for