简体   繁体   English

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

[英]Can't make Executable JAR file with library in Eclipse

I'm trying to export my project as executable jar, and all is good except one thing: there are 2 windows - the first is main jframe and second is jframe for making 3D surfaces using jzy3d library; 我正在尝试将我的项目导出为可执行jar,除了一件事之外一切都很好:有2个窗口 - 第一个是主jframe,第二个是用于使用jzy3d库制作3D表面的jframe; the first window contains button "Show" for executing the second jframe. 第一个窗口包含用于执行第二个jframe的按钮“Show”。 When I execute this project in Eclipse it works good, but when I make executable jar it is executed, but if I click by "Show" button the second jframe doesn't open. 当我在Eclipse中执行这个项目时,它运行良好,但是当我创建可执行jar时它会被执行,但如果我点击“Show”按钮,则第二个jframe不会打开。 So, please, tell me, how can I fix it? 那么,请告诉我,我该如何解决?

UPDATE: the info from cmd: 更新: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)

Probaly on command line you did not specify the classpath for jzy3d library Probaly在命令行上没有指定jzy3d库的类路径

You can run a jar file with lib: 您可以使用lib运行jar文件:

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

where you put your lib (jzy3d.jar) in the libs folder 你将lib(jzy3d.jar)放在libs文件夹中

If you have used some special tool that creates an executable jar file, then you have to configure that tool to include the jzy3d.jar lib to be used inside the exe. 如果您使用了一些创建可执行jar文件的特殊工具,那么您必须配置该工具以包含要在exe中使用的jzy3d.jar lib。

You'll need to do one of the following: 您需要执行以下操作之一:

  1. repack the contents of each jarfile dependency in your own executable jarfile 在您自己的可执行jarfile中重新包装每个jarfile依赖项的内容
  2. use an .exe wrapper such as Launch4j to pack your jarfiles into a self-extracting-and-launching executable 使用.exe包装器(如Launch4j)将jar文件打包成自解压并启动的可执行文件
  3. include the jarfile dependencies in the Class-Path attribute of your MANIFEST.MF when creating the executable jarfile from Eclipse, and include those dependencies in the appropriate relative location when you distribute your application 在从Eclipse创建可执行jar文件时,在MANIFEST.MF的Class-Path属性中包含jarfile依赖项,并在分发应用程序时将这些依赖项包含在相应的相对位置

Of the above options, 1 might be the easiest and most convenient for you. 在上述选项中,1可能是最简单,最方便的选择。 If you extract the contents of the jarfile dependencies into an Eclipse project, it is then very easy to include those resources when you create your jarfile using Eclipse's wizard. 如果将jarfile依赖项的内容提取到Eclipse项目中,那么在使用Eclipse的向导创建jar文件时,很容易包含这些资源。

Options 2 and 3 are also pretty straightforward but I would recommend making an ant script so you can have a 1-click build. 选项2和3也非常简单但我建议制作一个ant脚本,这样你就可以进行一次单击构建。

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

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