Calling DLLs in JAVA

Hi,
I need to create a utility for a component in a 3rd party tool. I am planning to create this utility in JAVA. But the problem is that the 3rd party tool uses DLLs which is created in VB 6.0 (Its seems so).
I came across the key word "NATIVE" in JDK. But the examples related to this is all given for C/C++. I am not sure whether following the same procedure we will be able to access any VB dlls.
Please help me out. I am aware that there are ceratin APIs which we can use as a Bridge between Dlls and Java. And If I am right one among such is JACOB. But I am trying to minimize the dependencies of my Java Code to any other Utilities.
Eagerly waiting for a valuable Advice
Jiju Jagadish

Hi,
It seems you'll need to compile you own DLL wrapper if you do not want to depend on 3rd party library, search for JNI spec here.
On the other hand generic wrappers save time, if you are not famillar with C/C++.
Look at that post : http://forum.java.sun.com/thread.jspa?threadID=722211&tstart=0
--Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Calling dll in Java using The JACOB Project

    Hi I'm trying to import and read the class and methods from a DotNet API (dll) in java code usind the Jacon Project does anybody know how to do it? (like and example or simple staps to have an idea)
    thanks
    Luca

    afaik you cannot call windows API functions directly, you have to create a 'wrapper' method in C++ in order to access the API functions.
    it will look something like
    // Java code:
    package a.b;
    class Thingie {
      public native int doThatFunkyThingie();
    // c++ code
    jint Java_a_b_Thingie_doThatFunkyThingie(JNIEnv *env, JObject j) {
      // c++ function calls go here
    }I haven't done JNI in over a year, so this is probably not entirely correct.
    I recommend you read the JNI tutorial.
    J

  • Calling DLLs or Java from Business Objects

    Post Author: nmarks
    CA Forum: Other
    I'm a newbie so please go easy!
    Is it possible to invoke a DLL or Java bean when opening a Business Objects query or report?
    I've just started working for a very large insurance company in the UK.
    Each month the company produces reports for the Directors, for the Auditors and Industry Regulators.
    Most of the results that go into the reports are produced using an extremely expensive application called Prophet. It dumps out files with data in.
    Ideally the company would like to upload the results from Prophet into Business Objects and have nice numbers show on a report the directors can understand.
    The problem is that lots of fiddly adjustment calculations have to be done to the data coming from Prophet before it can be shown on the BO report.
    I have proposed that the adjustment calculations are done using a VB DLL which will be called automatically by Business Objects  when the user wants to see the report. Can this be done?
    Can Business Objects call a DLL?
    Your help is very much appreciated.
    Regards,
    Nick.

    Post Author: thangvq
    CA Forum: Other
    Hello,
    I think it can. At least I have done it with a DLL is compiled by Delphi. You may read the CR Developer's Help for more info. If you have installed the Developer Edition, its location is something like this: C:\Program Files\Business Objects\Crystal Reports 11\Developer Files\Help\En
    Thang

  • How to call dll from Java

    Hi everybody,
    I am trying to call a dll from my java application. Pls tell me how to do it, I seached and found JNI. Is it true
    pls help me and send me some examples
    Thank you and have a nice day

    java_and_me wrote:
    I am trying to call a dll from my java application. Pls tell me how to do it, I seached and found JNI. Is it trueYes, it is true. JNI is the way to go. You'll probably have to write some C code on your own as well, as the DLL is unlikely to be in the format expected by Java already.
    pls help me and send me some examplesOf course. [Here you are|http://www.lmgtfy.com/?q=JNI+tutorial].

  • Call DLL from Java

    I have a dll wihtout source code. I do know the functions name and return type. How can I call the functions in this dll? Is JNI the only way to do it?

    YES, JNI is the only way you can call the DLL

  • 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

  • How to call VB dlls in java

    Hi
    I created one component in vb, where this component got 3 methods. and created dll also, when iam trying to use these dlls in java. it showing error, is there any method to call the vb dlls in java(native method), if s pls help me to solve these problem.

    hi, all
    I writed a vb dll, It have three publice sub and one preporty,
    I use html <object> attribute to declare this dll and call its methods and perporty in html file, everything is ok.the source code as following:
    <body>
    <OBJECT declare id="repExport" classid="clsid:0487D845-0DAD-46D0-9559-FADEC117C2B9">
    <param name="Exportfile" value="peiru">
    </OBJECT>
    <script language="vbscript">
    repExport.Exportfile="peiruyt"
    repExport.CrystalConnect()
    repExport.PassParameterRtp()
    repExport.reportexport()
    </script>
    Because i need get parameter from other web page , and i use weblogic 6.1 server, so i need change file type from html to jsp , But even if I just change the file extension from html to jsp, don't change any content in this file.
    then jsp cannot work, error message is "object don't support 'repExport.Exportfile' property", actual it don't support all three functions and a property
    Can anyone provide any help?
    thanks
    peiru

  • 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. :-)

  • Can we call DLL method in jave code

    hi,
    can we call DLL file method in java Code or program.

    See
    http://forum.java.sun.com/thread.jsp?forum=52&thread=179765

  • 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.

  • Call DLL function from JAVA

    HI!
    What's the best way (and simple) to call DLL function from JAVA.
    DLL function (developed in C) has two input parameters (string) and return an integer.
    Could you help with an example?
    Thanks a lot.

    Do a google search for 'JNI tutorial' and it will turn up hundreds of examples.

  • 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

  • To call a VB dll from java

    Hi,
    I want to know how one can call a VB dll from Java.I know it is something like calling a C dll which in turn calls the VB dll.I also went through the tutorial provided on the sun site and was able to call a C dll through java but I still do not know how to call a VB dll from java.
    regards,
    Anshuman

    Have you checked google?
    First hit. Reply 17.

  • Dll for java help...

    I 'd like to create a specific dll usable by java and i just have one dll not usable with java.
    i need your help if you know a routine, program .. that create automatically my dll for my java use.

    So im'going to be clear for people of all the world
    I'm working on a project in which i have to communicate with an video acquire board. I must retrieve video signal send by the camera to the video acquire board.
    Video acquire board constructor gives me a dll and a lib with functions but has not anticipated that maybe somebody will use a java program (Bad for me to be polite...)
    My problem is to call the methods of the constructor dll in java .I must use jni to generate a specific dll undertsood by java (dll containing a c and a h file with JNIEXPORT syntax.)
    But the constructor dll is not correctly written by the constructor to be interpreted by java.
    So the dll i must generate has to communicate with constructor dll and there, it is the dark side...
    Can you help me or have i lost you?

  • Ok writing DLLs in Java

    Can I compile a DLL using java! Or how about an ActiveX! And if I can how?

    You used to be able to this with Microsoft J++ (Visual Studio 6). I don't think this is supported any more though. There is a thing called J# which is part of .NET which will allow you to write code for the CLR (Common Language Runtime), but I doubt you will find it to be "pure" Java. It's more likely a "java-like" language as J++ was, and I don't know if you can write DLLs, I think it may only be ".NET Components" that you can write. (Don't really know much about this)
    If you are wanting to write an ActiveX DLL and want to do it in Java, I think you are probably barking up the wrong tree. If you don't want to go down the complete C++ path, you could try Visual Basic. VB is a simple language and it shouldn't take long to learn.
    If you are trying to access Windows features or applications not available from the standard Java APIs, then you will need to use JNI. Of course you will probably still have to code a C++ dll to act as a "wrapper" for your JNI class (JNI calls the wrapper which calls the native code).

Maybe you are looking for

  • DBIF_RSQL_SQL_ERROR while activating data in ODS

    Hi, I'm getting the following error when I try to activate the data in ODS. This is happening for all the ODSs in the system. SQL-ERROR: 603 ORA-00603: ORACLE server session terminated by fat al error System error: RSDU_ANALYZE_TABLE_ORA/ ORACLE ABAP

  • IPad 4 iOS 6.0.1 cannot connect to Facebook

    Hi all, I have a strange problem that I'm trying to solve. I have an iPad 2 (iOS 5.1.1), iPhone 4S (iOS 5.1.1) and now an iPad 4 (iOS 6.0.1) Using the WiFi network at work the new iPad cannot connect to Facebook properly. The two older devices, on iO

  • Problem in creating file on local machine

    Hello everbody... i m using forms and reports 6i i m creating file out_file := Text_IO.Fopen(:filepath || '.csv', 'a'); using this command in before_report trigger. And closing file in after_report trigger. here filepath is = \\IP address of local ma

  • Can't open files from Bridge in CS6

    All was good with CS6 until today - it will not open files from Bridge. Jpg and RAW, neither will open, it's driving me bananas! Any suggestions? Edit: Problem solved. I had overlooked an old version of PS 7.0 was still in my program files and CS6 Br

  • Help with broken display

    My MacBook Pro screen has recently died. It is out of warrenty and without AppleCare. For the time being I have been using an external display with the hdmi out adapter.  This has been fine apart from some slight issue with resolution. In trying to f