无法在Eclipse中使用库创建可执行JAR文件

时间:2012-11-30 18:57:26

标签: java eclipse

我正在尝试将我的项目导出为可执行jar,除了一件事之外一切都很好:有2个窗口 - 第一个是主jframe,第二个是用于使用jzy3d库制作3D表面的jframe;第一个窗口包含用于执行第二个jframe的按钮“Show”。当我在Eclipse中执行这个项目时,它运行良好,但是当我创建可执行jar时它会被执行,但如果我点击“Show”按钮,则第二个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)

2 个答案:

答案 0 :(得分:2)

在命令行上Probaly你没有指定jzy3d库的类路径

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

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

将lib(jzy3d.jar)放在libs文件夹中

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

答案 1 :(得分:0)

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

  1. 在您自己的可执行jar文件中重新打包每个jarfile依赖项的内容
  2. 使用.exe包装器(如Launch4j)将jar文件打包成自解压并启动的可执行文件
  3. 在从Eclipse创建可执行jar文件时,在MANIFEST.MF的Class-Path属性中包含jarfile依赖项,并在分发应用程序时将这些依赖项包含在相应的相对位置
  4. 在上述选项中,1可能是最简单,最方便的。如果将jarfile依赖项的内容提取到Eclipse项目中,那么在使用Eclipse的向导创建jar文件时,很容易包含这些资源。

    选项2和3也非常简单但我建议制作一个ant脚本,这样你就可以进行一次单击构建。