0

我正在尝试将我的项目导出为可执行 jar,除了一件事之外一切都很好:有 2 个窗口 - 第一个是主 jframe,第二个是使用 jzy3d 库制作 3D 表面的 jframe;第一个窗口包含用于执行第二个 jframe 的“显示”按钮。当我在 Eclipse 中执行这个项目时它运行良好,但是当我制作可执行 jar 时它被执行,但是如果我点击“显示”按钮,第二个 jframe 不会打开。所以,请告诉我,我该如何解决?

更新:来自 cmd 的信息:

Catched FileNotFoundException: C:\destination-natives-windows-i586.jar (═х єфр
ё  эрщЄш єърчрээ√щ Їрщы), while TempJarCache.bootstrapNativeLib() of jar:file:
:/destination-natives-windows-i586.jar!/ (file:/C:/ + destination-natives-wind
s-i586.jar)
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no glue
n-rt in java.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLo
erBase.java:454)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.
va:59)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JN
ibLoaderBase.java:90)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase
ava:328)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibr
y(DynamicLibraryBundle.java:390)
        at com.jogamp.common.os.Platform$2.run(Platform.java:249)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:231)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:183)
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:99)
        at org.jzy3d.global.Settings.<init>(Settings.java:12)
        at org.jzy3d.global.Settings.getInstance(Settings.java:21)
        at com.nda.fuzzy.views.SurfaceViewerFrame.<init>(SurfaceViewerFrame.ja
:102)
        at com.nda.fuzzy.views.MainFrame$26.actionPerformed(MainFrame.java:579
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknow
Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(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 So
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown So
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown So
ce)
        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)
4

2 回答 2

2

可能在命令行上您没有指定 jzy3d 库的类路径

您可以使用 lib 运行 jar 文件:

"java -cp libs/* -jar program.jar"

您将 lib (jzy3d.jar) 放在 libs 文件夹中的位置

如果您使用了一些创建可执行 jar 文件的特殊工具,那么您必须配置该工具以包含要在 exe 中使用的 jzy3d.jar 库。

于 2012-11-30T19:00:09.007 回答
0

您需要执行以下操作之一:

  1. 将每个 jarfile 依赖项的内容重新打包到您自己的可执行 jarfile 中
  2. 使用 .exe 包装器(例如 Launch4j)将您的 jarfile 打包成一个自解压和启动的可执行文件
  3. 从 Eclipse 创建可执行 jarfile 时,在 MANIFEST.MF 的 Class-Path 属性中包含 jarfile 依赖项,并在分发应用程序时将这些依赖项包含在适当的相对位置

在上述选项中,1 对您来说可能是最简单和最方便的。如果将 jarfile 依赖项的内容提取到 Eclipse 项目中,那么在使用 Eclipse 的向导创建 jarfile 时很容易包含这些资源。

选项 2 和 3 也非常简单,但我建议您制作一个 ant 脚本,以便您可以一键构建。

于 2012-11-30T19:19:25.497 回答