08-13-2013 09:07 AM
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";
}
}
Solved! Go to Solution.
08-13-2013 09:51 AM
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.
08-14-2013 09:08 AM - edited 08-14-2013 09:10 AM
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
08-14-2013 09:25 AM
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.
08-15-2013 08:54 AM
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
08-15-2013 09:43 AM - last edited on 11-06-2024 10:21 AM by Content Cleaner
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
08-15-2013 10:12 AM - edited 08-15-2013 10:13 AM
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:
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
09-13-2013 04:46 AM
Thanks alot flaborde.
I can now call a class in a package..
Kudo flaborde.