gpt4 book ai didi

java - 自治 java 可执行文件中的 netlogo

转载 作者:行者123 更新时间:2023-11-30 11:25:18 26 4
gpt4 key购买 nike

在 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

感谢您的推荐! cocoa

最佳答案

你需要做两件事:

1) 从类路径中删除 NetLogoLite.jarNetLogoLite.jar 用于小程序;在任何其他情况下将它放在类路径上只会造成伤害,而无济于事。

2) 添加 所有 NetLogo 的 lib 目录中的库 jar 到你的类路径中。

要完成#2,只需要将整个 lib 目录的副本放在与您正在使用的 NetLogo.jar 副本相同的位置。 NetLogo.jar 的 list 有一个类路径条目,它在以 lib/ 开头的相对路径名中查找支持的 jar。但是,如果您无法让它以这种方式工作——而且我不熟悉 NetBeans 或一般 IDE 中的类路径设置,所以我不知道在该特定上下文中是否会遇到任何困难——然后明确将该目录中的每个 jar 添加到类路径也应该有效。

关于java - 自治 java 可执行文件中的 netlogo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20329409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com