NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

java teststand - Error 1500 Cannot find class

Solved!
Go to solution

Hi everyone,

 

I am using TestStand 2010 and Java 1.7.

I try to add a java class in the Computer example folder, and call the method.

The java class is simply like below, because I just want to try calling my own java class.

I have set the Class Path in Start JVM to the directory where the Computer example (which is also the directory where I put my java class) are located.

 

TestStand can call the Computer's methods, but not mine (got error Error 1500 Cannot find class). I put my my java method calling among the defaults Computer example calls.

 

Furthermore I have read similiar threads but still I cannot solve the error.

 

Where is the part I miss, actually? Please share some insights.

 

Note: I even try to leave the Class Path empty, but TestStand still can call the Computer's methods. Why?

 

----------------------

 

public class TestJava {


public static void main(String[] args) {

}

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


}

 

0 Kudos
Message 1 of 8
(5,007 Views)

I do not modify any setting of SequenceFileLoad nor Setup in MainSequence of the Computer example.

Calling to the Computer's methods is just find. But I am struggling to call my own Java method.

Dont know what's wrong.

0 Kudos
Message 2 of 8
(5,003 Views)

Is the Java file compiled and named in a similar way as the example? I noticed the files in the examples directory are binary, not text/source files.

 

Also, your method is not static. It looks like there are two different step types, one for static methods and one for non-static ones. Are you using the right one?

 

I'm really not that familiar with Java or this example, just trying to help.

 

-Doug

0 Kudos
Message 3 of 8
(4,974 Views)

Hi Doug, 

 

Thanks a lot for your response. 

I do use TestJava.class, i.e the binary file, not a source file.

I have just found that apparently classes compiled with Java 1.7 are not supported.

I use earlier Java compiler (1.4 1.6) works fine.

 

But I now have other 2 problems:

1. It is annoying that changed class files are not in effect unless I close TestStand (closing Sequential editor .seq file does not help).

2. A class file residing in a package is not accesible by TestStand. I got 1500 error for that.

 

Anyone can share about those two issues?

Thank you.

0 Kudos
Message 4 of 8
(4,967 Views)

1. Perhaps the Unload All Modules menu item in the File menu might work. It should cause the module associated with the step type to get unloaded which might effectively unload the java runtime. I haven't actually tried it yet though, so I'm not sure. Please let us know if it works.

 

2. No idea, sorry. There is CVI source code for the Java step type in the examples directory, so, if you have CVI you might be able to extend it to work in this way. Or you can look at what the step type is doing in the source files and perhaps see why the problem is happening and/or rewrite it in another language if you don't have CVI.

 

Hope this helps,

-Doug

0 Kudos
Message 5 of 8
(4,935 Views)

See the online help for the Java example here:

 

https://www.ni.com/docs/en-US/bundle/teststand/page/java-step-types.html

 

See the Known Issues section. The inability to unload is a limitation of the JVM.

 

-Doug

0 Kudos
Message 6 of 8
(4,929 Views)
Solution
Accepted by yoppy

In order to load a class that is inside a package you have to use the package notation (or modify the example in order to use it). The path to the class is passed directly to the JVM in order to load the class, but really what is needed is the package from the class path including the full path to the class. 

 

That means you have to do the following:

 

1. Set the class path to the base directory where you built all your classes, if you have the following structure:

  • MyFile.java
  • builds
    • MyPackage
      • MyFile.class

You have to set the classpath to the builds directory

 

2. When you configure your steps, you have to set the path to the class in your Java steps to MyPackage/MyFile.class (note separator is a slash, not the usual Windows backslash, so the browse button doesn't quite help with that). 

 

 Another important thing is that when you set the classpath you are deleting the normal class path in Java, if you are using Java classes from the default libraries you might have to add <jre directory>\lib\rt.jar

Message 7 of 8
(4,927 Views)

Thanks alot flaborde.

 

I can now call a class in a package..

 

Kudo flaborde.

0 Kudos
Message 8 of 8
(4,815 Views)