Is it possible to call c# dll using JNI

Using JNI we can invoke native code written in c or c++.
Steps:
1) All we have to do is write a class and have a method of type native.
2) Invoke javah with -jni option to create a .h file.
3) Include this header file and implement the method in c or c++ code.
Now my question is:
Is it possible to call I want to know whether we can implement the native method in c# instead of c or c++.
Thanks

No you can't, but you can have the JNI C/C++ code call C# code. How to do that is no longer a JNI question but a C# question.

Similar Messages

  • Calling COM DLLs using JNI

    I am able to call ordinary dlls from my java application using JNI, by exporting the function from my DLL.
    What can I do to call COM DLLs using JNI which do not expose the
    Functions directly.
    please help!
    thanx,
    -sachin

    Is this a COM dll that you have written or do you merely have the dll?
    If you merely have the dll, there are some third party tools that will generate Java interfaces to COM objects from the dll.
    Although I don't endorse these products or work for them I've used them before with some success:
    o J-Integra -- http://www.intrinsyc.com/
    o jacoZoom -- http://www.infozoom.de/
    -- rob

  • Problem calling C# dll using JNI

    Hi,
    I'm trying to call C# functions from a JNI interface. I built a C++ DLL to link the Java and C# calls together, but I am always getting the same error. Calling the C# DLL directly from the C++ code (compiled as an application) does not cause this error. I have to be able to connect our java application with a third party C# DLL, so I cannot just right the DLL directly in C++... Here is my code:
    //C# Class Library::
    namespace ClassLibrary2
         /// <summary>
         /// Summary description for Class1.
         /// </summary>
         public class Class1     
              public Class1()
                   // TODO: Add constructor logic here
              public void Bidon1()
         MessageBox.Show("Affiche", "Toi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    //C++ DLL::
    #using "ClassLibrary2.dll"
    BOOL APIENTRY DLLMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {
      return TRUE;
    JNIEXPORT void JNICALL Java_com_blablabla_CommJNIDLL_Init
    (JNIEnv * enivronmt, jobject obj)
         new ClassLibrary2::Class1();
         (new ClassLibrary2::Class1())->Bidon1();
    Olivier dit :
    //Java JNI Calls::
    //From CommJNIDLL::
         static {
              System.loadLibrary("MyCDLL");
         public native void Init();     If I comment the calls within the C++ DLL, they get fired, and no exception is raised. What am I doing wrong?
    Thanks, bumpert

    Hi,
    I am currently also trying to call some C# code within JNI. So far I have managed to call some simple C# code in Java through JNI based on the example on codeproject. However, now my problem is that instead of doing JNI-->C++->M C++->C#, I need to include one more reference to some other DLLs in the C# code. Therefore I need to do JNI-->C++-->M C++-->C#-->DLL. So is there a way to do this? I can compile all the code sucessfully in C++, but when I try to execute the .netmodule (for C#) and DLL for C++ through JNI in Java, it gives me an error. I have tried to put all the relevant DLLs in the same directory, but it still does not work. So is there someway to combine the .netmodule of C# with the DLLs it references to? Perhaps that could solve the problem? I am new to C# and C++, really appreciate if someone can give some advices since there's nothing much on the net.
    thanks,
    Lee

  • Is it possible to call VB dll in Java

    Is it possible to call VB dll in Java?
    If yes then How?

    If you mean VB6 than you can call VB Module like a COM object with any Java-COM bridge.
    VB.NET could be called with my Object-Oriented JNI for .NET 1.1/2.0:
    http://www.simtel.net/product.php[id]95126[SiteID]simtel.net
    http://www.simtel.net/product.php[id]98653[SiteID]simtel.net

  • Is it possible to call a dll thru XI

    Hi ,
    Is it possible to call a dll thru XI .
    Thanks in advance
    Divya

    Hi Divya ,
    You can follow up these blogs and docs for your refrence
    /people/rashmi.ramalingam2/blog/2005/06/25/an-illustration-of-java-server-proxy
    /people/prasad.ulagappan2/blog/2005/06/27/asynchronous-inbound-java-proxy
    JDBC-XI-File Scenario
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d
    Regards
    Abhi

  • 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

  • Call to a C++ DLL, using JNI - C++ method has char*

    I am trying to link into an existing C++ Dynamically Linked Library(DLL) using the Java Native Interface(JNI).
    All goes fine, and the library loads into the current program, however when I try to call the function, it crashes. The function has char pointers, and I haven;t been able to get Java to simulate them. Is there a way?????
    I have tried using and array of chars .....char[], and String, but no dice.
    Any suggestions O'learned Java ones??

    It will be necessary for you to write a JNI adapter in C/C++ to accomplish this. Java character strings and arrays are very different from those of C/C++ and you'll have to use JNI functions to adapt.
    Chuck

  • How to call the .dll use Jave

    hello,
    I will to call a .dll file in java
    which function or API can do that ?
    if someone knows , please tell me .
    thanks

    You must define "native" methods in java. The native methods allow you to call out of java into C programs (dll's on Windows, so's on unix.)
    There is a java tutorial on native methods. Look for the buzzwords JNI, which is Java Native Interface.

  • Can it is possible to call two smartforms using single program.

    i am doing identification tag form. i wanted to display the output of program seperate for accepted qty. and rejected qty.By running program only one time.

    Hello!
    We made this code at a customer to call several different SAMRTFORMS from the printer program, like this.
    * SmartForm from customizing table TNAPR
      IF NAST-LDEST <> 'ZEP2' and NAST-LDEST <> 'ZEPH'.
        LF_FORMNAME = TNAPR-SFORM.
      ELSE.
        IF NAST-KSCHL = 'LD00'.
          LF_FORMNAME = 'ZSMARTFORM1'.
        ELSEIF NAST-KSCHL = 'LD99'.
          LF_FORMNAME = 'ZSMARTFORM2'.
        ELSE.
          LF_FORMNAME = TNAPR-SFORM.
        ENDIF.
      ENDIF.
    ...Additional program lines...
    * determine smartform function module for delivery note
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
             EXPORTING  FORMNAME           = LF_FORMNAME
    *                 variant            = ' '
    *                 direct_call        = ' '
             IMPORTING  FM_NAME            = LF_FM_NAME
             EXCEPTIONS NO_FORM            = 1
                        NO_FUNCTION_MODULE = 2
                        OTHERS             = 3.
        IF SY-SUBRC <> 0.
    *   error handling
          CF_RETCODE = SY-SUBRC.
          PERFORM PROTOCOL_UPDATE.
        ENDIF.
      ENDIF.
    Regards
    Tamá

  • Possible bug when loading dll through JNI

    Hi guys,
    I have come accross a strange occurance, if anyone can help me out i'd appreciate it lot.
    I have written an unmanged (MFC) dll which connects to a managed(.NET) dll.
    If I load the MFC dll without using any of the references to the managed dll everything is ok.
    But as soon as I include a call to initialize a managed member my java program just exits. Then if i try and run it again it gives me a stack overflow exception.
    The dll works absolutely 100% perfectly from other c++ applications (I've called all of its methods via a simple dos program), so it seems that there may be some protective layer that java is wrapping the dll in that isn't letting it make any managed calls.
    Has anyone had this problem before or know how to get around it?
    Below is the code from the unmanged (MFC) dll
         CNewDLLTestApp();
         void WriteToDevice(int Value);
         char ReadFromDevice();
            // this is the managed call, gcroot lets you call managed code from an unmanged area
         gcroot<JavaIntegrateManagedClass::Class1*>c;In the exposed java functions I initialize the class member c, and then call the regular dll functions.

    Sadly that is the complete error message.
    I've tried putting the load("DLL") in a try catch block but it never catches it. The debugger output screen just prints StackOverflowException.
    The JNI calling code doens't even get invoked at this point.
    * Class:     MainInterface
    * Method:    WriteToDevice
    * Signature: (I)V
    JNIEXPORT void JNICALL Java_MainInterface_WriteToDevice
      (JNIEnv *, jobject, jint Value)
         MessageBox( (HWND)NULL,"In java function","Unmanged DLL",MB_OK);
         //theApp.c->WriteToDevice(Value);
    }If I put the commented line back in the StackOverflowException occurs. If I leave it out everything is fine.
    c is a class within a managed DLL, which in turn links to a managed class.
    The layers may seem excessive but I understood it was needed to fool java into thinking it was calling unmanaged code.
    What I don't understand is how a standard C++ console application can make the calls no problem, but Java can't. Surely the execution of the dll process should be exactly the same.
    Thanks
    DRB2k5

  • How to solve these Errors when generating .dll (using JNI) ?

    Hello,
    I am very new about JNI. As I have been trying to generate my dll (sysHook.dll) as I followed this topic http://forums.sun.com/thread.jspa?threadID=632369 (by Jbgohlke ) by putting this command:
    cl -I"C:\Program Files\Java\jdk1.6.07\include" -I"C:\Program Files\Java\jdk1.6.07\include\win32" sysHook.cpp -FesysHook.dll Then many errors are popped up as follows:
    sysHook.obj :error LNK2019: unresolved external symbol __imp__CallNextHookEx@16 referenced in function "long__stdcall HookKeyboardProc(int,unsigned int,long)" (?HookKeyboardProc@@YGHIJ@Z)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__SetWindowsHookExA@16 referenced in function " void__cdecl Init(void)" (?Init@@YAXXZ)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__UnHookWindowsHookEx@4 referenced in function "void__Cleanup(void)" (?Cleanup@@YAXXZ)
    sysHook.dll : fatal error LNK1120: 3 unresolved externals
    If anyone of you know this PLEASE!! point me out!!
    [email protected]
    Thanks in advance

    Specify the appropriate library when linking.
    This is not a JNI question. It is a Windows/C/C++ programming question.
    Locking this thread.

  • Calling a third Party dll from java using JNI

    Hi
    I want an immediate help from u all.
    I have athird party c dll with .h and .lib file
    I wont be able to cahnge any thing in those files.
    I want to call the functions of that from my Java code.
    Ist possible to call the dll without writing any c or c++ wrapper over it?if yes , how to do it?

    Hi,
    You may use a generic wrapper like JNative.
    Commercial wappers also exists.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                               

  • Possible to call a transaction from a planning book using a macro button?

    Hi All,
    Is it somehow possible to call a transaction using a macro button in the planning book? Also, the current selection should be passed as input parameters to the transaction.
    In my example, I am trying to run the transaction /SAPAPO/MC90 - Release to Supply Network Planning from the Demand Planning  Planning Book/Data View. This way if planners need to change forecasts mid month for specific selections, they can easily transfer to SNP without having to go out of interactive planning.
    Thank you,
    Maria

    Hello Maria,
              It's possible to call a transaction from a planning book using a macro button.
    What you can do is ..... Create a function module and inside it use the command "Call Transaction Tcode"  (ABAPer can do this) to call ur specific transaction. And this module can in turn be called from your macro. Please find the below link which explanis how to call a function module from a macro. Do let me know if you need more information on this.
    Calling a function module from APO Macro
    Regards,
    Siva.

  • Is it possible to call a SOAP webservice using HTTP POST adapter

    Hello Experts,
    Is it possible to call a webservice using a HTTP adapter with POST method? If yes, how?
    Regards,
    Diptee

    No this will not work since you have additional SOAP information (i.e. SOAP envelope, security information) in addition to the payload. If you need a simple HTTP-Post for example, then you don't need SOAP, you can use the more simple http protocol without the additional features of SOAP.
    Also refer to this link for differences: Difference b/w SOAP and HTTP

  • Is it possible to call a non-JNI DLL

    I have a DLL I'd like to execute from Java, but do not have access to the source. From what I've read about JNI, it seems it requires Java specific code in the DLL source. Is there any other option? I need to pass it a String and it returns a String. Is Runtime.exec a viable option?
    Any advice would be greatly appreciated.

    OK... here is a scenario with some code snippets. I've done this with a C/C++ dll on windows....so if ur on some other OS you'll have to make appropriate changes(ditto for DELPHI).
    I have a dll called "myold.dll" written in C/C++ which has the following function signature
    int getVersion();
    My purpose is to call this function in the dll using JNI.
    For this you will need
    1. Header file of myold.dll (say myold.h)
    2. .lib file for myold.dll (say myold.lib)
    Now, write a java file "Mynative.java"
    public class Mynative {
    public native int getVersion();
       static {
          System.loadLibrary("Mynative"); //matches name of  new dll you are about to create
       public static void main(String[] args){
          Mynative nativity = new Mynative();
          int version = nativity.getVersion();
          System.out.println(version);
    }after compiling the above code, you will need to run javah
    on the resulting class file
    javah -jni Mynative
    Now you will have a header file Mynative.h which looks like
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class Mynative */
    #ifndef IncludedMynative
    #define IncludedMynative
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: Mynative
    * Method: getVersion
    * Signature: ()I
    JNIEXPORT jint JNICALL Java_Mynative_getVersion
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    Now create a C file say myCfile.c as follows
    #include <jni.h>
    #include "Mynative.h"
    #include <stdio.h>
    #include "windows.h"
    #include "myold.h" //Header file of the existing dll..you need this file!!
    JNIEXPORT jint JNICALL
    Java_Mynative_getVersion(JNIEnv *env, jobject obj)
    jint myInt;
    /* Call native function in Mynative.dll */
    myInt = getVersion();
    printf(myInt);
    printf("\n");
    return myInt;
    Now compile this file using a C compiler to create "mynative.dll".You'll have to know how to do that using whatever C/C++ compiler you use.
    This dll should be in any folder thats on the Java Classpath or else you are going to get an error.
    Well..you're set. You can run the java file and see the output.
    If however you do not have the header file for myold.dll, then you'll have to know how to dynamically load a dll in C/C++. Unfortunately, i don't know how so u'll have to ask someone else.
    Hope my efforts here don't go wasted. Good luck
    Vinny.

Maybe you are looking for

  • Split list view in finder

    Anyone know if there is any plugin (or app) for Finder that split list view in 2 independent columns, so I could drag and drop files (and folders) between folders more easily? Path Finder have this feature, but I wish to keep in finder (its free and

  • HTML file won't open in design view

    I've been asked to amend an existing website and so have retrieved a variety of necessary files. I thought it would just be a case of making the change and then putting the site back on the web but when I open the html file there is nothing showing i

  • MS Active Directory (LDAP) and SAP Integration

    Hi all! don't know if I'm right here in this forum, but: I'm using MS Windows Server 2003 and installed Active Directory as LDAP-System on the one hand side, on the other I'm using a 6.20 ABAP Web AS. I'd like to synchronize the User Storage on these

  • Undo segment & Rollback segment

    Hi, What is the difference between Undo segment & Rollback segment?Is it a standard practice of creating roll back segments for each tablespace? Regards, Cherry

  • What to do?  Premiere Pro CS5.5 has quit responding and won't play project.  Windows no recognize

    What to do when CS5.5 Premiere Pro does not respond.  Will not play project.  Seems to mess up even going to help.