LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Java -> COM -> LabView : Need Help

Dear Java Community:

Can anyone suggest why my 20 line Java program below fails at the end?

The "labview50.*" package is generated with Microsoft's "jactivex" tool
operating
on the file LabView/resources/labview50.tbl.

This program actually does bring a labView session alive and can
communicate
with the "Application" object.

However, even though the "labView.GetVIReference( )" statement executes
without
exception or error, ANY attempt to use the return VirtualInstrument
object always
results in the following error:

java.lang.ClassCastException: Illegal cast from class
com/ms/com/CUnknown to
interface labview50/VirtualInstrument. Class does not declare
interface and inter
face
does not have an IID.

Any Suggestion at all appreciated.

STeve Punte
stevep@hamsoft.com

PS:
Equivalent C++ seems to work.



import java.awt.*; // standard java
import java.awt.event.*;
import java.applet.*;
import com.ms.ui.*; // afc controls
import com.ms.activeX.*; // used for our control host
import com.ms.com.*; // general com

import labview50.*;

public class Foo
{
public static void main(String args[])
{
// Instantiate a LabView session. Class Application knows the GUID
Application labView = new Application();

// This works.
System.out.println("Application Name = " + labView.getAppName() );

// Load up a VI program
VirtualInstrument vi =
labView.GetVIReference( "C:\\test.vi", new com.ms.com.Variant("") );

// ALWAYS Bombs here, no matter what member function is attempted.
vi.getName();
}
}
0 Kudos
Message 1 of 1
(1,656 Views)