2012-11-30 52 views
0

我試圖將我的項目導出爲可執行jar,除了一件事情之外,所有的都很好:有兩個窗口 - 第一個是主jframe,第二個是jframe,用於製作使用jzy3d庫的3D曲面;第一個窗口包含執行第二個jframe的按鈕「Show」。當我在Eclipse中執行這個項目時效果很好,但是當我製作可執行jar時,它會被執行,但如果我點擊「Show」按鈕,第二個jframe就不會打開。所以,請告訴我,我該如何解決它?無法在Eclipse中使用庫執行JAR文件

最新消息:來自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

請發佈您的錯誤/堆棧跟蹤。 – Frank

+1

我沒有執行任何消息 – user1841247

+0

不是雙擊jar文件,而是打開一個終端窗口(又名控制檯或CMD或命令提示符),'cd'到包含jar文件的目錄,並運行'java -jar yourjarfilename.jar'。然後你會在終端窗口看到錯誤信息。 – rob

回答

2

Probaly在命令行中沒有指定的類路徑jzy3d庫

您可以運行以lib jar文件:

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

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

如果您已經使用過一些特殊的工具,創建一個可執行的jar文件, 然後你必須配置該工具,以包括jzy3d.jar庫在exe中使用。

+0

我不通過命令行通過Eclipse製作JAR。你能幫我嗎? – user1841247

+0

你如何運行它? – AlexWien

+0

我已經做出可執行的jar文件 - 我通過點擊來執行它.. – user1841247

0

你需要做以下之一:

  1. 改裝每個jar文件依賴的內容在自己的可執行jar文件
  2. 使用一個.exe的包裝,如Launch4j收拾你jarfiles中成自解壓並啓動的可執行文件
  3. 在從Eclipse創建可執行jarfile時,在MANIFEST.MF的Class-Path屬性中包含jarfile依賴項,並在分發應用程序時將這些依賴項包含在適當的相對位置

上述選項中,1可能是最簡單和最方便的。如果將jarfile依賴項的內容提取到Eclipse項目中,那麼在使用Eclipse嚮導創建jarfile時,可以很容易地包含這些資源。

選項2和3也非常簡單,但我會建議製作一個ant腳本,以便您可以進行一次單擊構建。

+0

請看我的堆棧跟蹤 – user1841247