在Netbeans中,我能够运行NetLogo并将数据传输到另一个java程序(两个不同的线程)。
现在,我想构建一个可执行的java程序,以便按原样使用它。
问题是我启动exe时出现以下错误消息:
java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at org.nlogo.awt.EventQueue$.invokeAndWait(EventQueue.scala:19)
at org.nlogo.app.App$.main(App.scala:157)
at org.nlogo.app.App.main(App.scala)
at emulateur.Emulateur_ec.main(Emulateur_ec.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)
Caused by: java.lang.NoSuchMethodError: scala.collection.TraversableLike.collect(Lscala/PartialFunction;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
at org.nlogo.swing.ToolBar.addNotify(ToolBar.scala:44)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at javax.swing.JRootPane.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at java.awt.Window.addNotify(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.pack(Unknown Source)
at org.nlogo.swing.MessageDialog.<init>(MessageDialog.java:57)
at org.nlogo.window.RuntimeErrorDialog.<init>(RuntimeErrorDialog.java:109)
at org.nlogo.window.RuntimeErrorDialog.init(RuntimeErrorDialog.java:35)
at org.nlogo.app.App.org$nlogo$app$App$$finishStartup(App.scala:426)
at org.nlogo.app.App$$anonfun$main$1.apply$mcV$sp(App.scala:157)
at org.nlogo.swing.Implicits$$anon$17.run(Implicits.scala:12)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
我理解“java.awt.EventQueue.invokeAndWait”错误行在这里是因为java程序开头的以下行
App.main (ch);
appli = App.app();
try
{
java.awt.EventQueue.invokeAndWait
(
new Runnable ()
{
public void run()
{
try
{
App.app().open(...);
}
catch (java.io.IOException ex )
{
ex.printStackTrace ();
}
}
}
)
};
但我真的不知道如何解决它!
为了构建可执行文件,我包括(如在netbeans项目中)NetLogo.jar和NetLogoLite.jar
感谢您的推荐! Cocq广场
答案 0 :(得分:1)
你需要做两件事:
1)从类路径中删除NetLogoLite.jar
。 NetLogoLite.jar
仅存在 ,用于applet;在任何其他场景中将它放在类路径上只会伤害,从不帮助。
2)将NetLogo的lib
目录中的所有库库添加到类路径中。
要完成#2,只需要将整个lib
目录的副本放在与您正在使用的NetLogo.jar副本相同的位置。 NetLogo.jar的清单有一个类路径条目,用于查找以lib/
开头的相对路径名的支持jar。但是如果你不能以这种方式工作 - 我不熟悉NetBeans或IDE中的类路径设置,所以我不知道是否期望在特定的上下文中有任何困难 - 然后明确将该目录中的每个jar添加到类路径中也应该可以。