08-13-2016 09:10 PM
Hi all,
Can any one please help to import a java or .jar file to labview
08-14-2016 03:34 AM
08-14-2016 01:40 PM - edited 08-14-2016 01:47 PM
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 ...
08-15-2016 04:15 AM - edited 08-15-2016 04:17 AM
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.