NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Classpath to .jar

I try to create a step in sequence editor to execute a Java class developed by me (following the Computer.seq Java example given). The Java class uses API packaged in a .jar file.
 
I tried to
1. set the classpath to the jar file in Edit Java Class Path Location for Start JVM step and
2. extract the classes in the jar into a directory set in Configure/Search Directories. 
 
When executing the step, I got the following error:
Details: Error executing substep 'Post'.
             Cannot find class
Error Code: -1500; User-defined error code.
 
Please advice.
 
Thanks
0 Kudos
Message 1 of 4
(3,505 Views)
Hi Wong,
 
If you check this error code within the ReadMe in the example folder you can see that this error means "The provided class name was not found in the class path. Verify the class name and that the file containing the class exists in the class path."  Therefore, I think that you may have the incorrect class path set.  Although you selected in the Edit Java Class Path Location and browsed to your jar file, there are a couple things happening here that I believe are causing you to get the error.  First, the dialog is looking for a folder directory that contains your class files, not a jar file.  Also, make sure you point to a folder and not a specific file.  Also, if you look at the pre-expression of this step, you will see that it sets the class path to the example folder.  This value is overwriting anything that you place in the dialog box.  Therefore, delete the pre-expression for the step and then add the directory that your classes are located in to the Edit Java Class Path Location dialog box.
 
Let me know if this helps you.
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 2 of 4
(3,472 Views)
Keep in mind that you do not need to extract all the files from the .jar archive to use them. As long as the Java class you developed is outside the .jar file you should be able to use any classes from the .jar file (note that even though the step type does not support directly calling classes inside a .jar archive, you can add support for this by modifying the source if needed).
0 Kudos
Message 3 of 4
(3,465 Views)

Hi all,

 

I have a class like below. I create sequence file based on the Computer example. Other method calls are working except my Java class.

I got error 1500, cannot find class. Does TestStand support package fille?

I copy javaexample folder (which contains JavaExample.class), to the Computer example folder.

I have tried to set class path in StartJVM and Configure-> Search Directories. Change here and there, until the point that I am not what I am doing.. 

 

 

If TestStand really support package file, please help, what should I set (class path, search directories..)?

Preferably step by step instruction, assuming I extend it the Computer working example.

 

Thank you.

 

 

 

 

 

package javaexample;


public class JavaExample {


public static void main(String[] args) {

System.out.println("Printing....");
System.out.println( new JavaExample().returnString(false));
}

public String returnString(boolean a){
return "String returned";
}
}

0 Kudos
Message 4 of 4
(2,774 Views)