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)                                                                                                                                                                                                                               

Similar Messages

  • To read a DLL from java using JNI

    Hi,
    I had some DLL files (VB 5.0) which are providing interfaces. Is there any chance of accessing that using java (JNI). Also is there any De - Compiler available so that I can get the source code of the DLL file.
    Regards,
    Hari.

    Hola Hari
    To make a dll loadable through JNI, the interface
    inside
    the dll must be implemented the JNI way. Also a COM
    interface does not help.
    I would reccomend a certain product to automatise the
    JNI interfacing process, but that would
    require that you have the sourcecode of the dll
    available.
    But one thing you can do is to write a wrapper that
    contains the dll classes and is implemented the JNI
    way.
    More precisely you write an interface wrapper in c/c++
    that matches the methods of the dll and does use JNI
    methods. Now inside that c++ wrapper you load the dll
    and forward the calls from java to c++ vice versa.
    Download the demo version of CENTRO.java here:
    www.ablon.de
    Bye, nilsHi Nils,
    Thank you for your suggestion. Im new to JNI.
    That dll's are in Visual Basic. I don't have the source code of the dll file. I got the interfaces available in the dll file from a Visual Basic program which make use of the dll file(which we are talking about). As I know only the method signatures in the interfaces(dll file), I request you to kindly provide me some help to wrap it in C/C++ program.
    Thanks in advance.
    Regards,
    Hari.

  • Executing DLLs from Java using JNI vs Runtime.exec()

    I am trying to understand the best way to execute a dll using java. The dll I am testing with takes a few input parameter. If I use JNI with System.loadLibrary("dll"); what do I need to do to pass the arguements in as well? Can I just add the arguements in the java code like private int xyz = "value"; and expect that the dll will accept them or is there special definitions I have to set up in the dll to make it work?
    Alternatively I was looking at using Runtime to execute the dll by using Runtime.exec("dll param1 param2",env,filePath); Does anyone know if there are drawback to doing it this way vs. using JNI or is this just as efficient? Any help would be appreciated.

    You seem to be confused...
    "execute a dll using java"
    Unless I'm mistaken, a dll is not executable. A dll is a library of code. This code has (hopefully) some well-defined entry points (declared in a header file somewhere) which you must call in a C/C++ file. The arguments you pass to the dll will come from java through JNI.
    As far as your understanding of this entire process, it is obviously confused beyond the scope of a simple reply. I recommend you read the examples and ALL of the documentation available here:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    When you get the/an example running (or just set up to run) then post your code and comments here for more help.
    Ian

  • How To Call A Third Party DLL ?

    Hi All,
    I do have a dll file written in C/C++. I need to call it from java.
    I do have all the function declarations & descriptions, but not the source of the dll.
    I want to call those methods in java. I know that I have to use JNI for this. But dont know how to do it ?
    please guide me to do it .
    Thanks in Advance.

    Matthijs@ wrote:
    Just speaking for myself:
    It is a bad idea to learn C/C++ using JNI.I'm not trying to learn C++ using JNI. Instead, I have an existing DLL written in C++, and I want to call it from Java. Simple as that. Why do I want to call it from Java? Because I have a lot of existing Java code that I need to integrate with this DLL.
    If you already know C/C++ then it should be rather obvious how to do what you stated.I don't know C++, so I guess it's not obvious.
    To use JNI you need to know C or C++.
    There are alternative wrappers (which actually use JNI dynamically) that have the goal of letting you do it without C/C++.
    However the complexity of that comes from understanding that one is still interfacing with a native method which often has a C/C++ structure (figuratively but possibly literally as well.) As the complexity of the native API the chance that someone with no C/C++ experience figuring out the correct way to use it goes down.
    You can research jnative (also called JNA) for this approach.
    Not however that questions about JNA (or other wrappers) on this forum/site are unlikely to get answers. There might be other sites where that is different. On the other hand JNI will almost always get answers.
    As a general programming concept JNI exists to provide a layer between disparate layers. Thus again it should be obvious that one will in fact need to write JNI code to access a native library.Sure. Never said I didn't expect to write JNI code. The thing that bothers me is that the one good resource I found on JNI spends I don't know how many pages explaining how to write the native code with method names like Java_Class_x etc. In my and the OP's scenario the DLL can't be modified, so the immediate question that comes to mind is: if the methods have to be called Java_etc, how can I make this work with my DLL? Of course, perhaps if you sit down and think about it, you might figure out that you can write C++ code that wraps the DLL, and then use JNI to call that code. However, this might not be so easy to figure out for people that are not programming wizards like yourself, and nonetheless have a need to integrate Java with C++. Although I am no wizard, I'm no beginner either (in Java, at least) but I didn't think of it until after reading the relevant chapter (I admit that I then had a slap-forehead "of course!" moment).
    Again the point is that you must know C/C++ first.
    From the "The Java Native Interface" book from Sun first page of the introduction
    "The book assumes that you have basic knowledge of the Java, C and C++ programming languages..."
    My point is: since integrating existing code of both languages should be the most common use case for JNI, why not provide an explanation about this scenario up front in the documentation? Something like: "if you have an existing DLL, you will need to write some C++ code that calls that DLL. In the following, we will explain how you can make the C++ code you write yourself callable from Java with JNI. Chapter 9 goes into more detail about how to write wrapper code for existing DLLs." Just so people that are not Einstein and are in a hurry can figure out where to go quickly.
    And my point is that what you are stating was immediately obvious the first time I saw the JNI specification.
    Anyone that tries to "go quickly" with C/C++ code is going to end up crashing the application (whether it is C/C++ code or JNI code.)
    My second point is: the [Guide to Features/JNI|http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html] that ejp urged the OP to Google for is rubbish. Most people don't want a JNI specification, they want a tutorial. The [Java Native Interface tips|http://java.sun.com/products/jdk/faq/jnifaq.html] page is slightly less rubbish, but it still stinks. It doesn't explain anything. Try following the "resources on the Net" links. 3 out of 5 are broken or it is explicitly stated that they are outdated. The other 2 are decent, but again don't provide a straight statement on the most common scenario. Why doesn't either the guide to features or the tips page provide a link to the [JNI Tutorial and Programmer's Guide|http://java.sun.com/docs/books/jni/html/jniTOC.html]?
    You would need to provide some actual numbers to support your contention as to what "most people" want.
    Most developers never use JNI at all.
    As for the spec being rubbish if a developer claimed experience in C and C++ and yet claimed they didn't understand the spec then myself I would question their contention that they actually knew C/C++.
    For someone who doesn't know C/C++ then the first step is to learn those.
    It would also be handy to have a basic idea of how shared libraries (on any OS) work and how to dynamically use such libraries (versus statically.)
    My third point is: why be so rude to the OP almost from the start?Obviously the first question is why you think it is necessary that you need to comment on something that didn't involve you in the first place.
    But other than that the posters on these forums answer a lot of questions and the forum is NOT for any of the following
    1. Teaching someone how to program
    2. Teaching someone how to ask questions
    3. Teaching someone how to think logically.
    4. Teaching someone how to design.
    5. Teaching anyone about etiquette.
    6. Anything at all except java.
    So for example we do not nor should anyone expect us to teach a beginning programmer how to program in C/C++. And we need not be polite when we tell someone that the forum is not suited for those purposes.

  • Deploying third party dll from solution

    Hi,
    I am creating a visual webpart in which i have added the Telerik RadGrid.
    I have added the Telerik.web.UI dll in the Reference and is refered from the GAC. I have build the solution and grid works fine in my local dev environment.
    I would like to know how to package the solution, so that the third party dll is also added to the GAC and to the safe controls.
    How to achieve this? If possible, please elaborate the steps.
    Thanks

    Hi Mahindrakar,
    I have used the right name of the dll in my code. I didn't understand, what you are saying about readme file ?
    I getting the following error with
    Stack Trace:
    [NullReferenceException: Object reference not set to an instance of an object.]
    Certification.VisualWebPart1.VisualWebPart1UserControl.Page_Load(Object sender, EventArgs e) +187
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
    System.Web.UI.Control.OnLoad(EventArgs e) +131
    System.Web.UI.Control.LoadRecursive() +65
    System.Web.UI.Control.AddedControl(Control control, Int32 index) +349
    Certification.VisualWebPart1.VisualWebPart1.CreateChildControls() +154
    System.Web.UI.Control.EnsureChildControls() +145
    System.Web.UI.Control.PreRenderRecursiveInternal() +60
    System.Web.UI.Control.PreRenderRecursiveInternal() +223
    System.Web.UI.Control.PreRenderRecursiveInternal() +223
    System.Web.UI.Control.PreRenderRecursiveInternal() +223
    System.Web.UI.Control.PreRenderRecursiveInternal() +223
    System.Web.UI.Control.PreRenderRecursiveInternal() +223
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3393
    One thing, i know very well, only problem in adding reference only.
    The above thing may helpful for you, giving me solution.
    Thanks
    Aasai.

  • How to access data structures in C dll from java thru JNI?

    We have been given API's( collection of C Functions) from some vendor.
    SDK from vendor consist of:
    Libpga.DLL, Libpga.h,Libpga.lib, Along with that sample program Receiver.h (i don't know its written in C or C++), I guess .C stnads for C files?
    Considering that I don't know C or C++ (Except that I can understand what that program is doing) & i have experience in VB6 and Java, In order to build interface based on this API, I have two option left, Use these dll either from VB or Java.
    As far as I know, calling this DLL in VB requires all the data structures & methods to be declared in VB, I guess which is not the case with Java (? I'm not sure)
    I experiemnted calling these function from Java through JNI, and I successfully did by writting wrapper dll. My question is whether I have to declare all the constants & data structures defined in libpga.h file in java, in order to use them in my java program??
    Any suggesstion would be greatly appreciated,
    Vini

    1. There are generators around that claim to generate suitable wrappers, given some dll input. I suggest you search google. Try JACE, jni, wrapper, generator, .... Also, serach back through this forum, where there have been suggestions made.
    2. In general, you will need to supply wrappers, and if you want to use data from the "C side" in java, then you will need java objects that hold the data.

  • How to call third party software from Ecc6 using ABAP

    Hi all,
    I need to execute a third party software using abap coding .
    The software converts doc to pdf, the input from ecc6 would be the file path.
    I need to do this using ABAP.
    thanks
    ziv.

    Hi Ziv
    You can use METHOD cl_gui_frontend_services=>execute
      EXPORTING
        application            = <<<.exe file>>>
        operation              = 'OPEN'
    to run .exe files
    Best Regards
    Yossi

  • Calling a third-party library from JNI-enabled C++ code

    Hi everyone,
    I have some existing C++ application code that extracts data from a file in a special format (HDF5). This code uses a static library (third party) to decode the file format. I would like to wrap this application code in a JNI wrapper so that I can call the code from Java. So I have a situation like this:
    Java front end -> application code (C++) -> static library (C++)
    I have compiled JNI headers and modified the application code accordingly. I created a shared library by bundling the application code together with the static library (using gcc 3.2.2 on Red Hat Linux 9):
    g++ -shared hdf5_jni.cc -o libhdf5_jni.so -I<include path> -L<static library path> -lhdf5
    (the <static library path> contains the static library libhdf5.a). This creates a shared library which contains the application code and the relevant bits of the static library.
    When I call the Java front end, the shared library (libhdf5_jni.so) is correctly found and accessed. However, I get an UnsatisfiedLinkError which I don't understand:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: <blah>/lib/libhdf5_jni.so: <blah>/lib/libhdf5_jni.so: undefined symbol: _Z4formPKcz
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
    ... etc
    I have no idea what the undefined symbol "_Z4formPKcz" represents. It's not part of the application code or the static library.
    Here's some more info that might help diagnosis:
    1) The problem seems to be due to the approach of having a three-step process (Java code calling bespoke shared library which includes unmodified 3rd-party code). I get an identical error (including the mysterious "_Z4formPKcz" symbol) when trying to do something similar with a different 3rd-party static library.
    2) When I simply have Java code calling C++ code which I have written myself (no calls to static library methods), I have no problems, i.e. there doesn't seem to be a problem with the way I set up the JNI wrappers or the application code, or in the way I create the shared library.
    3) When I simply have C++ code calling the static libraries (i.e. no Java wrapper) I have no problems, i.e. there doesn't seem to be a problem with the application code or the static libraries.
    4) The static libraries were compiled from source using the same compiler that I used to compile the application code.
    5) I'm using J2SDK 1.4.2 on Red Hat Linux 9, although I've tried other versions of the SDK and had the same problem.
    I've done a lot of web searches on the "_Z4formPKcz" symbol and have turned up absolutely nothing (zero Google hits!).
    Any help would be very much appreciated.
    Thanks, Jon

    Thanks chrisswhite,
    I should have mentioned that I tried this too and it didn't solve the problem. You're right though, I should be compiling with -fPIC anyway.
    Jon

  • Error calling a third party WSDL from BPEL

    Hi,
    I am trying to invoke a third party WSDL. This WSDL belongs to Oracle OPPM. When I call this wsdl from SOAPUI or even from the Enterprise Manger, it works fine.
    However, when I call it from BPEL, it is giving me an error. Here is the request and error response:
    Request
    <messages>
    <input>
    <Login_Input>
    <part name="sUser">
    <sUser xsi:type="def:string">Username</sUser>
    </part>
    <part name="sPassword">
    <sPassword xsi:type="def:string">Password</sPassword>
    </part>
    <part name="lTimeOut">
    <lTimeOut xsi:type="def:int">10</lTimeOut>
    </part>
    </Login_Input>
    </input>
    Response
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <remoteFault>
    <part name="summary">
    <summary>Server was unable to read request. ---> There is an error in XML document (1, 2168). ---> <Login xmlns='http://tempuri.org/'> was not expected.</summary>
    </part>
    <part name="detail">
    <detail>oracle.j2ee.ws.client.jaxws.JRFSOAPFaultException: Client received SOAP Fault from server : Server was unable to read request. ---> There is an error in XML document (1, 2168). ---> <Login xmlns='http://tempuri.org/'> was not expected.</detail>
    </part>
    <part name="code">
    <code>{http://schemas.xmlsoap.org/soap/envelope/}Client</code>
    </part>
    </remoteFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>
    I checked the diagnostics logs and it is not giving me any further information.
    I think the issue is with the WSDL file. I tried importing the WSDL locally too, but I cannot get rid of this error.
    I also tried to import the namespace in the <WSDL:Types> area, but no luck.
    WSDL
    <?xml version="1.0" encoding="utf-8"?>
    <wsdl:definitions
         targetNamespace="http://tempuri.org/"
         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
         xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
         xmlns:s="http://www.w3.org/2001/XMLSchema"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
         xmlns:tns="http://tempuri.org/"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
         xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
        >
        <wsdl:types>
        </wsdl:types>
        <wsdl:message name="DebugSoapIn"/>
        <wsdl:message name="DebugSoapOut"/>
        <wsdl:message name="LoginSoapIn">
            <wsdl:part name="sUser" type="s:string"/>
            <wsdl:part name="sPassword" type="s:string"/>
            <wsdl:part name="lTimeOut" type="s:int"/>
        </wsdl:message>
        <wsdl:message name="LoginSoapOut">
            <wsdl:part name="Result" type="s:string"/>
        </wsdl:message>
        <wsdl:message name="ReleaseSecurityTokenSoapIn">
            <wsdl:part name="sSecurityToken" type="s:string"/>
        </wsdl:message>
        <wsdl:message name="ReleaseSecurityTokenSoapOut"/>
        <wsdl:message name="GetCurrentUserIDSoapIn">
            <wsdl:part name="sSecurityToken" type="s:string"/>
        </wsdl:message>
        <wsdl:message name="GetCurrentUserIDSoapOut">
            <wsdl:part name="Result" type="s:int"/>
        </wsdl:message>
        <wsdl:portType name="psPortfoliosSecurityRpcSoap">
            <wsdl:operation name="Debug">
                <wsdl:input message="tns:DebugSoapIn"/>
                <wsdl:output message="tns:DebugSoapOut"/>
            </wsdl:operation>
            <wsdl:operation name="Login">
                <wsdl:input message="tns:LoginSoapIn"/>
                <wsdl:output message="tns:LoginSoapOut"/>
            </wsdl:operation>
            <wsdl:operation name="ReleaseSecurityToken">
                <wsdl:input message="tns:ReleaseSecurityTokenSoapIn"/>
                <wsdl:output message="tns:ReleaseSecurityTokenSoapOut"/>
            </wsdl:operation>
            <wsdl:operation name="GetCurrentUserID">
                <wsdl:input message="tns:GetCurrentUserIDSoapIn"/>
                <wsdl:output message="tns:GetCurrentUserIDSoapOut"/>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="psPortfoliosSecurityRpcSoap" type="tns:psPortfoliosSecurityRpcSoap">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="Debug">
                <soap:operation style="rpc" soapAction="http://tempuri.org/action/psPortfoliosSecurity.Debug"/>
                <wsdl:input>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="Login">
                <soap:operation style="rpc" soapAction="http://tempuri.org/action/psPortfoliosSecurity.Login"/>
                <wsdl:input>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="ReleaseSecurityToken">
                <soap:operation style="rpc" soapAction="http://tempuri.org/action/psPortfoliosSecurity.ReleaseSecurityToken"/>
                <wsdl:input>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="GetCurrentUserID">
                <soap:operation style="rpc" soapAction="http://tempuri.org/action/psPortfoliosSecurity.GetCurrentUserID"/>
                <wsdl:input>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="psPortfoliosSecurityRpc">
            <wsdl:port name="psPortfoliosSecurityRpcSoap" binding="tns:psPortfoliosSecurityRpcSoap">
                <soap:address location="http://dc01oppmsv01.molina.mhc/ProSightSOAP/psPortfoliosSecurityRpc.asmx"/>
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    Thanks
    Asif Hussain

    Thanks chrisswhite,
    I should have mentioned that I tried this too and it didn't solve the problem. You're right though, I should be compiling with -fPIC anyway.
    Jon

  • Calling existing C/C++ dll from Java Prog

    Hi,
    From within the Java code I want to use the
    functionality of an existing C API. The dll's of C are available. Is it possible to directly call the C Api using Jni or some other technique or do I need to implement a native method in C which would Use the existing C Api to get the values and Pass them to the Java prog.
    Istikhar.

    Is it possible to directly call the C Api using Jni...Depends on what you mean. You can't call it directly from java. You can use JNI, including C/C++ to call it.

  • Can I call a C function from Java (using JNI) ??

    hello,
    I need to call one C function from remote device and get its return value(o/p) (for my application it is device SSID ) and display in the client PC.
    Is it possible in java without using SNMP connction?.
    please give me idea about it.
    I need this information as soon as possible.
    Thank you.

    see JNI...
    basically declare a native method in your java class, then run javah on the class thus generating a *.h file. Then implement the c/c++ function. Compile the c/c++ part as a shared library, and make sure its accessible from your LD_LIBRARY_PATH env variable.
    Go through the steps in the JNI docs, and things shoulde be fine... hopefully ;)

  • Fall into a trouble when calling a dll from java in linux

    Hi, experts:
    I encountered a big trouble when using JNI to call a C++-compiled DLL from java in Linux: The DLL function didn't execute immediately after the invocation, and was deferred till the end of the Java execution. But all worked well after migrating to windows. This problem made me nearly crazy. Can somebody help me? Thanks in advance.
    Linux: fedora core 8, jdk1.6.0_10,
    compile options: g++ -fPIC -Wall -c
    g++ -shared

    It looks like the OP compiled the C source file and linked it into a Windows .dll, which would explain why it worked flawlessly in Windows. (Though I must say the usage of GCC would make someone think it was compiled in Linux for Linux, GCC also exists for Windows, so I'm not sure it's a Windows .dll either...)
    @OP: Hello and welcome to the Sun Java forums! This situation requires you to make both a .dll and a .so, for Windows and Linux. You can then refer to the correct library for the operating system using System.loadLibrary("myLibrary"); without any extension.
    s
    Edited by: Looce on Nov 21, 2008 11:33 AM

  • How to use Third Party DLL in Adobe Illustrator Plug In

    Hi Everyone,
    I want to design plug-in for Adobe illustrator CS6(64 bit). As first step I am referring sample plug ins from ../SDK/SampleCode. I am not getting how to use third party DLL in plug in.
    Please let me know how to refer C# DLL in illustrator plug in.
    Thanks in advance.

    There's no C# API for the Illustrator SDK, so your plugin must be C++ at the very least. That said, you can probably write a bridge if you need to call out to a C# library/DLL.

  • Calling back c++ method in an exe (not a dll) from java?

    Hi all,
    I have to make an hybrid C++/java from an existing C++
    application that compiled is a big single exe not a dll.
    I'm running under win32.
    The application consists of several windows. The hybrid
    will have widows in C++ and some in java. They have the
    same menu and tool bar. In the C++, there are some
    callbacks called when a button is pressed. How to call
    these callback from java given the fact that the JVM and
    the java classes are launched by the exe file.
    I know how, from C++, start JVM and call my java window.
    I also know how to call a C++ method that is in a dll from
    java. It's from the tutorial
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    But I don't know how to call a C++ method that is in in an
    exe which has launch a JVM from an object running in this
    JVM.
    Is there somewhere an example like this?
    Thanks,
    Xavier.

    Thanks this helped.
    For those who want a complete example, here it is:
    Tested on XP, java 1.4.2, VC++ 6.0.
    ************ File invoke.cpp *****************************
    #include <stdlib.h>
    #include <jni.h>
    #ifdef _WIN32
    #define PATH_SEPARATOR ';'
    #else /* UNIX */
    #define PATH_SEPARATOR ':'
    #endif
    #define USER_CLASSPATH "." /* where Prog.class is */
    void JNICALL displayHelloWorld(JNIEnv *env, jobject obj)
        printf("Hello world: made by printf from C++\n");
        return;
    void main() {
        JNIEnv *env;
        JavaVM *jvm;
        JavaVMInitArgs vm_args;
        jint res;
        jclass cls;
        jmethodID mid;
        jstring jstr;
        jobjectArray args;
        char classpath[1024];
         int result;
        /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
         JavaVMOption options[3];
         options[0].optionString = "-verbose:gc";
         sprintf (classpath, "-Djava.class.path=%s", USER_CLASSPATH);
         options[1].optionString = classpath;
         options[2].optionString = "-Djava.compiler=NONE";
         vm_args.options = options;
         vm_args.nOptions = 3;
         vm_args.ignoreUnrecognized = JNI_TRUE;
            vm_args.version = JNI_VERSION_1_4;
         /* IMPORTANT: Note that in the Java 2 SDK, there is no longer any need to call
          * JNI_GetDefaultJavaVMInitArgs. It causes a bug
        /* Append USER_CLASSPATH to the end of default system class path */
        /* Create the Java VM */
        res = JNI_CreateJavaVM(&jvm,(void**)&env, &vm_args);
        if (res < 0) {
            fprintf(stderr, "Can't create Java VM\n");
            exit(1);
        cls = env->FindClass("mypackage/Prog");
        if (cls == 0) {
            fprintf(stderr, "Can't find mypackage/Prog class\n");
            exit(1);
       JNINativeMethod nm;
       nm.name = "displayHelloWorld";
       /* method descriptor assigned to signature field */
       nm.signature = "()V";
       nm.fnPtr = displayHelloWorld;
       env->RegisterNatives(cls, &nm, 1);
        mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
        if (mid == 0) {
            fprintf(stderr, "Can't find Prog.main\n");
            exit(1);
        jstr = env->NewStringUTF(" from C++! calleded by C++, using argument from C++ but java method");
        if (jstr == 0) {
            fprintf(stderr, "Out of memory\n");
            exit(1);
        args = env->NewObjectArray(1,
                            env->FindClass("java/lang/String"), jstr);
        if (args == 0) {
            fprintf(stderr, "Out of memory\n");
            exit(1);
        env->CallStaticVoidMethod(cls, mid, args);
        jvm->DestroyJavaVM();
    }********************* File ./mypackage/Prog.java **************************
    package mypackage;
    public class Prog {
           public native void displayHelloWorld();
        public static void main(String[] args) {
            System.out.println("Hello World" + args[0] +"\n");
            Prog prog = new Prog();
            prog.displayHelloWorld();
            System.out.println("(called from java)");
            System.out.println("\nSo to sumurize:");
            System.out.println(" -1 Starting point is an exe (not DLL, there is no DLL) so C++ code");
            System.out.println(" -2 From C++ call java method using argument from C++");
            System.out.println(" -3 From java, that was launched by the exe, call to");
            System.out.println("    a native using the RegisterNatives in C++\n");
            System.out.println("You got a bidirectional example with as starting point");
            System.out.println("a single exe, launching JVM, loading class call back C++!");
    }******************* Command line for all ****************************************
    javac mypackage/Prog
    cl -I"D:\Program Files\j2sdk1.4.2_03\include" -I"D:\Program Files\j2sdk1.4.2_03\include\win32" -MT
    invoke.cpp -link D:\PROGRA~1\j2sdk1.4.2_03\lib\jvm.lib
    (Remark, the last path is using the short name for "Program Files" because with the blank
    even adding double quotes result into an error)
    You must have jvm.dll in your path for me it's Path=D:\Program Files\j2sdk1.4.2_03\jre\bin\client;
    Then simply call invoke and see the result. :-)

  • Convert word document in PDF,e pub,by using third party dll in Sharepoint designer workflow 2013?

    Hi,
    I want to convert word document to PDF,  EPub, by using third party (.dll).
    In SharePoint designer workflow in 2013.
    So that I have question, Can we Install third party (.dll) in SharePoint workflow Designer for conversion?
    Means I have created one simple application conversion of word to e Pub, PDF, Image by using (Spire.doc dll) in Visual Studio.
    So this same conversion I want to work in SharePoint designer workflows?
    So anybody has any solution then please provide me.
    Thanks,
    Samadhan

    it might be worth looking at these CodePlex steps, that plug directly into the Word Automation Services.
    http://sp2010wordautomation.codeplex.com/
    It'll provide you with a configurable step like the below that should help you achieve your aims
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

Maybe you are looking for

  • Create a PDF as attachment in custom module in mail receiver adapter

    I'm trying to create a PDF attachment to an email using a custom module with the following codes. The attachment was created and sent, but when I tried to open it, I got the following error message: the file cannot be read either because a invalid en

  • Satellite M70: WLAN connection lost

    Hello! I have Satellite M70 and I use integrated Intel WLAN card 2200bg. I have the latest drivers downloaded from Toshiba web site and Asus WLAN router w520g with latest firmware. Connection signal is excellent but sometimes actually very often conn

  • Mouse Pointer Location

    How can i get where the mouse pointer is inside a jframe opened up in full screen mode. I want to be able to tell exactly where the mouse pointer is, from any component i have inside the screen. For example when calling the rendering. Some components

  • Inspection plan with multiple specifications

    I have to maintain 1 inspection plan for 2 vendors for incoming inspection. Eg: Vendor A & B Vendor A, I have to check parameter Fe, Mn, Si Vendor B, I have to check parameters Fe, Moisture (For B, no need to check Mn, Si. Also Fe specification will

  • Can't see my files

    After reinstalling  Maverick from Apps store, some of my files are not visible in their folders. Document, Video. pictures,  download are on the disk but won't show in the finder's windows. Thanks Robert