LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute JavaScript

I have written a JavaScript function within a .js file to transform XML using a Stylesheet. I would like to execute this from within CVI.
I can execute the function from the command line by passing the XML file and the XSLT Stylesheet as arguments but this doesn’t work using the LaunchExecutable function.

I’ve also tried using the XMLDOM functions provided within CVI to convert the XML but can’t seem to get my head round it.

Any ideas would be much appreciated.

Thanks,
James
0 Kudos
Message 1 of 3
(3,602 Views)
Hi James,


In order to access Java methods from LabWindows/CVI or inversely, to access LabWindows/CVI functions from Java, you need to use something called the "Java Native Interface", or "JNI" for short.


With the Java Native Interface you can invoke Java class methods and access properties (such as strings and arrays) from "native code" modules (such as C-based .dlls or .exes) by calling specific methods within the JNI that cause the Java Virtual Machine to execute the classes and return data to you from the executions. Inversely, you can also call native code functions from within a Java class by using the JNI to create native functions that are callable from Java.


Also it might be best to use a C IDE like LW/CVI to create a wrapper
dll that exposes functions calling into the JNI internally.

From LabWindows/CVI you would use the JNI just as you would with any other C or C++ IDE to either invoke Java methods or use native code functions from within your Java classes. Information for these tasks is universally covered within Sun Corp.'s JNI documentation linked to below.


To find a detailed explanation of how to use the JNI with your Java and native code please refer to the following Sun Corp. website tutorial:
JNI Overview.



http://java.sun.com/docs/books/tutorial/native1.1/

Hope this tutorial and the explanation above, would help you out with your problem.

Best Regards

Atul Wahi
National Instruments
Applications Engineer
www.ni.com
Message 2 of 3
(3,602 Views)
Hi James,


In order to access Java methods from LabWindows/CVI or inversely, to access LabWindows/CVI functions from Java, you need to use something called the "Java Native Interface", or "JNI" for short.


With the Java Native Interface you can invoke Java class methods and access properties (such as strings and arrays) from "native code" modules (such as C-based .dlls or .exes) by calling specific methods within the JNI that cause the Java Virtual Machine to execute the classes and return data to you from the executions. Inversely, you can also call native code functions from within a Java class by using the JNI to create native functions that are callable from Java.


Also it might be best to use a C IDE like LW/CVI to create a wrapper dll
that exposes functions calling into the JNI internally.

From LabWindows/CVI you would use the JNI just as you would with any other C or C++ IDE to either invoke Java methods or use native code functions from within your Java classes. Information for these tasks is universally covered within Sun Corp.'s JNI documentation linked to below.


To find a detailed explanation of how to use the JNI with your Java and native code please refer to the following Sun Corp. website tutorial:
JNI Overview.



http://java.sun.com/docs/books/tutorial/native1.1/

Hope this tutorial and the explanation above, would help you out with your problem.

Best Regards

Atul Wahi
National Instruments
Applications Engineer
www.ni.com
0 Kudos
Message 3 of 3
(3,602 Views)