ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call LabVIEW DLL in Java (JNI)

Hi,
 
I would like to know how to call LabVIEW DLL in Java (JNI).
 
I have searched in the forum and some mentioned that I need to have a wrapper DLL that exports the "JNI-style" names and calls the names exported from the LV-built DLL. I do not know what does this means??
 
I want to use JNI to control GPIB so I want to build 488.2 or VISA vis into DLL which I can call in JNI. Could anyone guide me in doing this?? What are the steps and how to do it??
 
JNI and LabVIEW
 
Thank you & Regards
Lee
Message 1 of 3
(5,209 Views)
More things to add...
 
I have found websites that mention that I need to have a header which is generated by JNI to be included in the LabVIEW DLL header so that JNI can use this LabVIEW DLL in JNI. How do I do that??
 
Both links below have information on calling DLL in Java (JNI).
 
Calling Native C/C++ code (in a DLL) from Java using JNI
 
Java Native Interface: Programmer's Guide and Specification
 
I am using LabVIEW 8.20 and found that I could not add in external header when building DLL in DLL properties. I can only add additional LabVIEW headers but not other external headers. Does that mean that I need to build the JNI header and call it in my vi before I build this vi into DLL to include JNI header in my DLL header?? Could anyone advise me on this??
 
Thank you & Regards
Lee
0 Kudos
Message 2 of 3
(5,202 Views)
Hi,

I don't have particular information about how to make calls from Java to LV DLL, but I'll describe
you how to make a wrapper DLL.

So, beside the LV DLL, you'll need another DLL that works as an interface to the LV DLL. In this
DLL, you'll have to write a function that matches every function in your LV DLL. I'll give some code
sample in C.

void /*some calling conventions and JNI specific stuff*/ loadLVLib()
{
    // load the LV library in to memory. The calls are different for each platform (and compiler),
    // but in VC++ for example, this is done with the LoadLibrary() function.
    // This will give you handle to the library
}

void /*Again some calling convections and JNI stuff is required*/ doDAQOperation()
{
    // use the handle to make a call to LV function. You can do this with GetProcAddress()
    // in VC++, there's also other means to do this.
}

void /*JNI etc stuff*/ releaseLVLib()
{
    // in VC++, one would use FreeLibrary() function in here.
}

I think this should give you an idea of the wrapper. If you have more questions about this,
post them and I'll try to give you an answer.
0 Kudos
Message 3 of 3
(5,190 Views)