LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing a .Jar file to LabVIEW

Hi all,

 

Can any one please help to import a java or .jar file to labview

AB
Kudos are Accepted
0 Kudos
Message 1 of 4
(4,000 Views)
Iam not sure how.jar can be directly imported into LabVIEW but converting it to .NET then you can easily import as suggested from http://forums.ni.com/t5/LabVIEW/How-can-we-link-Java-Code-with-LabView/m-p/408186/highlight/true#M20...
-you can get info on importing .NET to LabVIEW from here : http://digital.ni.com/public.nsf/allkb/DCB90714981A1F148625731E00797C33
Thanks
uday
Message 2 of 4
(3,969 Views)

Not sure why you'd want to "import" a Java Archive into LabVIEW, but the file, itself, at the top level is a ZIP file.  What happens if you use LabVIEW's UnZip function on it (found in the File I/O Palette)?  It should at least get you some of the contents, and you can see what you might want to do with them.

 

Bob Schor

 

P.S. -- I just tried it with a .jar file I found in Program Files.  It gave me a Manifest.mf file and two .class files, neither of which I've tried to open.  My conclusion is that this First Step works ...

0 Kudos
Message 3 of 4
(3,947 Views)

While the file format of a Java Archive is indeed a ZIP file with a certain internal file structure you can do nothing with that contents from within LabVIEW. The Java Archive contains the *.class files which is basically Java Byte Code compiled from the original Java source code (and optionally other files such as configuration files used in the code or binary compiled shared libraries that the Java code uses through JNI). Only a compliant Java virtual machine knows how to load and execute these files properly. Since LabVIEW is not a Java virtual machine, it can do nothing with these files.

 

Importing a Java library into LabVIEW is more complex than importing a shared library (DLL) or a .Net component into LabVIEW. You first have to compile the Java Libary into a shared library through special tools, or convert it to .Net, which for any non-trivial library isn't a simple push the button exercise either. While .Net was heavily inspired by Java (some claim the C# developers copied most Java features directly and added some C(++) specialismes to it), no Java to .Net converter can completely convert complex Java code into .Net without some extra handholding and code modifications afterwards. If your code is so trivial that the converters work without extra work, your code is most likely simple enough to be directly reimplemented in LabVIEW in the same amount of time it will take to figure out what tools to use and install for the conversion.

 

If it is a specialistic library without any existing .Net or shared library alternative, then the effort may be justified, but in most cases it is wasted effort as you most likely have alternatives to the Java library that already have been developed directly in C(++), C# or even in LabVIEW.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(3,912 Views)