简体   繁体   English

从我的类文件在IDE netbeans中运行jar文件

[英]running jar file from my class file in the IDE netbeans

I use a jar file called korat.jar. 我使用了一个名为korat.jar的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. 类路径包含jar的路径以及Add.class文件。

I want to execute this jar in my own program java in netbeans IDE. 我想在自己的NetBeans IDE程序Java中执行此jar。 I think I would use: 我想我会用:

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

Korat.main(s); Korat.main(s);

I get this exception: java.lang.NoClassDefFoundError 我收到此异常: java.lang.NoClassDefFoundError

What do you mean "to execute the jar in my own program"? 您是什么意思“在我自己的程序中执行jar”? The jar contains some classes, if they are in your class path, you can instantiate the classes themselves and invoke some methods. 该jar包含一些类,如果它们在您的类路径中,则您可以实例化这些类本身并调用某些方法。 In that case, you should use test.Add class. 在这种情况下,您应该使用test.Add类。 But it seems like the class is not in your classpath - java.lang.NoClassDefFoundError. 但是似乎该类不在您的类路径中-java.lang.NoClassDefFoundError。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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