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.

Similar Messages

  • 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

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

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

  • How to access Data Guard option in Oracle 10g OEM

    Hi All,
    I have Oracle 10g ENTERPRISE EDITION on Unix envoirement. I want to setup logical standby Database through Data Guard technology. But when I brows through OEM I do not find Link for DATA GUARD????
    1) How to access Data Guard option from oracle 10g OEM.
    2) Does It come with Enterprise Edition OR I have to install it separately.
    Regards,
    Darshan

    I am managing almost everything through EM Grid Control. It is easy to setup and configure.
    Anyways, if you have read the documentation on
    Oracle® Data Guard Concepts and Administration and setup your environment accordingly then you should not have any problems. Atleast I can assure you that your production database will not be affected by it.
    Just make sure that you follow each step and read thoroughly. If you have spare machines then you can test and record your configuration before performing it on your production db. This link will provide you with the information on DataGuard.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14239/concepts.htm
    If you think that way then you will never be able to do any new stuff since you will always fear that something might go wrong. Go ahead pal, try it on test machines and you will know that it is not that difficult.
    There are real experts who help people like us in this forum and I know that they are doing a pretty good job.
    All the best.
    Rgds
    Adnan

  • How can access data in rman output file "daily.log"

    Hi All,
    i did use following query for rman out
    output file "daily.log" has been created,but does not exist data.
    how can access data in output file "daily.log"
    bash-3.00$ sh rmant.sh
    Recovery Manager: Release 10.2.0.3.0 - Production on Thu Jun 30 16:54:16 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    connected to target database: DEV (DBID=45558086)
    RMAN> Spool log to daily.log;
    2> run
    3> {
    4> backup databas;
    5>}
    6> spool log off;
    7>
    Spooling started in log file: daily.log
    Recovery Manager10.2.0.3.0
    Starting backup at 30-JUN-11
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=634 devtype=DISK
    channel ORA_DISK_1: starting compressed incremental level 0 datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    input datafile fno=00014 name=/u02/proddata/a_int01.dbf
    input datafile fno=00022 name=/u02/proddata/a_txn_data01.dbf
    input datafile fno=00023 name=/u02/proddata/a_txn_data02.dbf
    input datafile fno=00024 name=/u02/proddata/a_txn_data03.dbf
    input datafile fno=00039 name=/u02/proddata/a_txn_data04.dbf
    input datafile fno=00038 name=/u02/proddata/undo02.dbf
    input datafile fno=00027 name=/u02/proddata/a_txn_ind03.dbf
    input datafile fno=00028 name=/u02/proddata/a_txn_ind04.dbf
    input datafile fno=00012 name=/u02/proddata/undo01.dbf
    input datafile fno=00015 name=/u02/proddata/a_media01.dbf
    input datafile fno=00025 name=/u02/proddata/a_txn_ind01.dbf
    input datafile fno=00026 name=/u02/proddata/a_txn_ind02.dbf
    input datafile fno=00029 name=/u02/proddata/a_txn_ind05.dbf
    input datafile fno=00021 name=/u02/proddata/a_summ01.dbf
    input datafile fno=00019 name=/u02/proddata/a_ref01.dbf
    input datafile fno=00020 name=/u02/proddata/a_ref02.dbf
    input datafile fno=00001 name=/u02/proddata/system01.dbf
    input datafile fno=00002 name=/u02/proddata/system02.dbf
    input datafile fno=00003 name=/u02/proddata/system03.dbf
    input datafile fno=00004 name=/u02/proddata/system04.dbf
    input datafile fno=00005 name=/u02/proddata/system05.dbf
    input datafile fno=00006 name=/u02/proddata/system06.dbf
    input datafile fno=00007 name=/u02/proddata/system07.dbf
    input datafile fno=00008 name=/u02/proddata/system08.dbf
    input datafile fno=00009 name=/u02/proddata/system09.dbf
    input datafile fno=00010 name=/u02/proddata/system10.dbf
    input datafile fno=00011 name=/u02/proddata/system11.dbf
    input datafile fno=00013 name=/u02/proddata/a_archive01.dbf
    input datafile fno=00036 name=/u02/proddata/sysaux01.dbf
    input datafile fno=00016 name=/u02/proddata/a_nolog01.dbf
    input datafile fno=00037 name=/u02/proddata/izu01.dbf
    input datafile fno=00017 name=/u02/proddata/a_queue01.dbf
    input datafile fno=00018 name=/u02/proddata/a_queue02.dbf
    input datafile fno=00031 name=/u02/proddata/odm.dbf
    input datafile fno=00034 name=/u02/proddata/portal01.dbf
    input datafile fno=00035 name=/u02/proddata/sfx01.dbf
    input datafile fno=00030 name=/u02/proddata/ctxd01.dbf
    input datafile fno=00032 name=/u02/proddata/olap.dbf
    input datafile fno=00033 name=/u02/proddata/owad01.dbf
    channel ORA_DISK_1: starting piece 1 at 30-JUN-11
    channel ORA_DISK_1: finished piece 1 at 30-JUN-11
    piece handle=/sw/weekly_cum_database_DEV_t755196858_c1_s24_p1 tag=WEEKLY_CUM_DAT
    ABASE comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:32:55
    channel ORA_DISK_1: starting compressed incremental level 0 datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    including current control file in backupset
    including current SPFILE in backupset
    channel ORA_DISK_1: starting piece 1 at 30-JUN-11
    channel ORA_DISK_1: finished piece 1 at 30-JUN-11
    piece handle=/sw/weekly_cum_database_DEV_t755198834_c1_s25_p1 tag=WEEKLY_CUM_DAT
    ABASE comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
    Finished backup at 30-JUN-11
    Spooling for log turned off
    Recovery Manager10.2.0.3.0
    Recovery Manager complete.
    bash-3.00$

    i did try this but it hangs
    bash-3.00$ sh rmant.sh
    Recovery Manager: Release 10.2.0.3.0 - Production on Fri Jul 1 10:52:01 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    connected to target database: DEV (DBID=45558086)
    RMAN> Spool log to 'daily' append;
    2> run
    3> {
    4> backup as backupset
    5> incremental level=0 cumulative
    6> device type disk
    7> tag "weekly_cum_database"
    8> format '/sw/weekly_cum_database_%d_t%t_c%c_s%s_p%p'
    9> database;
    10> }
    11>

  • I am tryin to access old macbookpro harddisk on macbook air,when i connect it via usb i see the folders,but i dont see any files e.g. photos,movies,docs are not there,its shows that 220gb is used,but no data is visible...can u pls adv how to access data?

    i am tryin to access old macbookpro harddisk on macbook air,when i connect it via usb i see the folders,but i dont see any files e.g. my saved photos,movies,docs are not there,its shows that 220gb is used,but no data is visible...all folder are empty.......can someone pls adv how to access data?

    i am tryin to access old macbookpro harddisk on macbook air,when i connect it via usb i see the folders,but i dont see any files e.g. my saved photos,movies,docs are not there,its shows that 220gb is used,but no data is visible...all folder are empty.......can someone pls adv how to access data?

  • How to process data in the past based from data in the present

    hello guys,
    i have a problem in my labview programs. how to process data in the past based from data in the present ?
    i have a formula self-organizing maps
    this formula is looking for D1, D1 is neuron index that will be searched for the smallest value.and the result are D1=2 ,D2=5, D3=17 from calculating with formula  .it means the smallest value is 2, "2" from weight [2 2] in file attached.
    and then it will be in other formula
    it mean [2 2] + 0.5 ( [1 1]-[2 2] ) = [1.5 1.5]
    and the weight will be  [1.5 2 2 ] in matrix
                                              1.5 3 5
    I would appreciate any input/help on solving this
    thanks
    Attachments:
    dika.vi ‏16 KB
    weight.txt ‏1 KB
    data .txt ‏1 KB

    Hi Ronny Hanks,
    Moving your records from internal table into the database table depends upon various scenarios :-
    1. If you use INSERT statement.
    INSERT <database_table> FROM TABLE <internal_table>.
    But in this case, you need to make sure that you don't have any duplicate entries in your internal table that violates data entry into database table, else you will get a dump.
    INSERT <database_table> FROM TABLE <internal_table> ACCEPTING DUPLICATE KEYS.
    In this case, you are forcefully inserting duplicate records into your database table which may lead to data redundancy in your database table.
    2. If you use UPDATE statement.
    UPDATE <database_table> FROM TABLE <internal_table>.
    This will update the existing records in your database table from the internal table.
    3. If you use MODIFY statement.
    MODIFY <database_table> FROM TABLE <internal_table>.
    This statement works both in combination of INSERT & UPDATE statements.
    Existing records (in database table) will be eventually updated/modified and new records (not in database table currently) will be successfully inserted into the database table.
    Hope this solves your problem.
    Thanks & Regards.
    Tarun Gambhir.

  • How can i pass string from C++ DLL to Java via JNI?

    Hi everybody. I made a DLL with Borland C++. I must pass a string from this dll to Java via JNI.Namely i define a string variable in C++ DLL and i send this variable's value to Java via JNI.
    I can pass integers but i couldnt Strings. . How can i do this? is there any sample?

    Hi,
    So your function should be private static native String get_text();
    (It's often a good idea to make native methods private since when you change signatures you generally have to change java wrapper methods only).
    I know nothing about C++ strings but I'm pretty sure that you can convert it to char*, so
    do :
    char* szMyString = myString.toChar*();
    Then return from native with JNU_NewStringPlatform(env, szMyString)
    (see my 1st answer for JNU_NewStringPlatform() description).
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to Select data using same column name from 3 remote database

    Hi,
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
    Ex.
    SELECT *
    a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
    FROM
    *((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
    *(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
    WHERE b.dept = 'finance'
    AND a.position = 'admin'
    AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
    GROUP BY a.name, b.status ;
    NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
    Thanks in advnce. :)
    Edited by: user12994685 on Jan 4, 2011 9:42 PM

    user12994685 wrote:
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
    Each object must be uniquely identified. So you cannot do this:
    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
    ERROR at line 1:
    ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
    ERROR at line 1:
    ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    DUM DUM
    X   X
    SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution.

  • How to Access the value(Ex: Delivery no) From Web to R/3 side.

    How to Access the value(Ex: Delivery no) From Web to R/3 side.
    Any sample code please suggest.
    sai

    Hi,
    Try RSA3.
    Extract Checker
    /people/sajeed.ms/blog/2006/02/12/extract-checker
    Thanks,
    JituK

  • How to get  data with the raw pattern from resultset ?

    would you tell me how to get data with the raw pattern from resultset ?
    thank you in advance!
    longgger2000

    I tried getBytes() and getObject()
    , but I can not get the right result , for example the
    data in oracle database is 01000000DFFF, when In used
    the method of getBytes() and getObject(), I get the
    result of [B@1c2e8a4, very different , please tell me
    why !
    thank you
    longgger2000
    [B is byte arrayseem that it return an bytes array for you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to access JNDI tree of Admin Server from Managed Server

    Hello,
    I created Managed and Admin Server for Domain.
    On Managed Server I use:
    InitialContext con = new InitialContext()
    It points to Managed Server local JNDI tree and
    Managed Server can't find JNDI tree of Admin Server.
    Looks like Managed Server is regular remote client of Admin Server.
    How to access JNDI tree of Admin Server from Managed Server?
    Thanks.
    Oleg.

    Hello,
    I created Managed and Admin Server for Domain.
    On Managed Server I use:
    InitialContext con = new InitialContext()
    It points to Managed Server local JNDI tree and
    Managed Server can't find JNDI tree of Admin Server.
    Looks like Managed Server is regular remote client of Admin Server.
    How to access JNDI tree of Admin Server from Managed Server?
    Thanks.
    Oleg.

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

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

Maybe you are looking for