简体   繁体   中英

running jar file from my class file in the IDE netbeans

I use a jar file called korat.jar. I executed with the command line:

java -cp $CLASSPATH korat.Korat --visualize --class test.Add --args 3

The classpath contains the path of the jar and also the Add.class file.

I want to execute this jar in my own program java in netbeans IDE. I think I would use:

String []s={test.Add.class.getName(),"--visualize","--class","test.Add","--args","3"};

Korat.main(s);

I get this exception: java.lang.NoClassDefFoundError

What do you mean "to execute the jar in my own program"? The jar contains some classes, if they are in your class path, you can instantiate the classes themselves and invoke some methods. In that case, you should use test.Add class. But it seems like the class is not in your classpath - java.lang.NoClassDefFoundError.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM