2017-01-12 7 views
3

であり、私はそれが私はちょうど私の最初の本当のJAVAのプログラムを完了しjava.lang.NoClassDefFoundErrorが、しかし、すべてのjarファイルが解決場所

動作するようになりました。これは、.xlsxファイルを開くプログラムで、このファイルからデータを抽出し、textAreaに表示します。

eclipseでは、プログラムは正常に動作しますが、エクスポートされたjarは機能しません。プロジェクトがエクスポートされたら、私はCMDでjava -jar c://を使ってそれを開きます。それはうまくいきます。私はこのエラーを取得するExcelファイルを開こうとするしかし:だから、基本的に

Error message

必要な.jarファイルの一つは、実行時に利用可能ではないように思われます。しかし、私はpoi-3.9とxmlbeansのすべてが利用可能であると信じています。これを参照してください:

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry exported="true" kind="lib" path="src/xmlbeans-2.3.0.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-examples-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-excelant-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-ooxml-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-ooxml-schemas-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/poi-scratchpad-3.9-20121203.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/log4j-1.2.13.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/junit-3.8.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/commons-logging-1.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="commons-collections4-4.1-javadoc.jar"/> 
    <classpathentry exported="true" kind="lib" path="commons-collections4-4.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/commons-codec-1.5.jar"/> 
    <classpathentry exported="true" kind="lib" path="poi-ooxml-3.9.jar"/> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    <classpathentry exported="true" kind="lib" path="lib/commons-codec-1.10.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/commons-io-2.5.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.4.jar"/> 
    <classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/cssparser-0.9.20.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/htmlunit-2.23.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/htmlunit-core-js-2.23.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/httpclient-4.5.2.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/httpcore-4.4.4.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/httpmime-4.5.2.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/jetty-io-9.2.18.v20160721.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/jetty-util-9.2.18.v20160721.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/neko-htmlunit-2.23.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/serializer-2.7.2.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/websocket-api-9.2.18.v20160721.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/websocket-client-9.2.18.v20160721.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/websocket-common-9.2.18.v20160721.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/xalan-2.7.2.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.11.0.jar"/> 
    <classpathentry exported="true" kind="lib" path="lib/xml-apis-1.4.01.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/jsoup-1.10.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/dom4j-1.6.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/selenium-server-standalone-3.0.1.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/stax-api-1.0.1.jar"/> 
    <classpathentry kind="lib" path="src/poi-ooxml-3.11.jar"/> 
    <classpathentry exported="true" kind="lib" path="src/xbean-2.0.0.jar"/> 
    <classpathentry kind="output" path="bin"/> 
</classpath> 

ビルドパスの設定で私の注文とエクスポートタブも参照してください。

Export

私は何かが足りないのですか?どんな助けでも大歓迎です!

EDIT: 私はいくつかの変更を行い、すべての必要なjarファイルは私のプロジェクトのlib /フォルダにあります。 jarをエクスポートし、jar tf "location.jar"を使用してjarの内容を表示すると、次のようになります。私は次のようになる。だから、これはすべてがきれいに輸出されていることを意味します。私は同じエラーが発生し続けるため、何が間違っている可能性があります上の任意の提案。

Contents of JAR and Classpath

+0

なぜ 'src'にライブラリがありますか? – MozenRath

+0

アーカイバでjarファイルを開き、ライブラリのjarファイルがlibフォルダにあることを確認して、jarファイルが正しい方法でパックされていることを確認してください。 – sphinks

+0

まだ2つのチェックが依存jarファイルにありませんので、すべてチェックしてから試してみてください。 – NarendraR

答えて

2

これは、日食があなたのクラスパスの依存関係を読み込み、実行時にそれらを含むが、java -jarコマンドでエクスポートしたjarファイルを実行するためので、あなたはJVMが瓶いることを知っているように-cp <your-jar-locations-semicolon-separated>を追加する必要がありますです実行中のクラスパスに含まれるべきである。

代わりに、エクスポートされたjar内のすべての依存するjarを含む影付きのjarファイルを作成します。

+0

ありがとう!私は-cp を追加する方法がわかりません。私はたくさんの瓶を持っていますが、それらをすべて-cp行に追加する必要がありますか?残念ながら、はい。 – Diederik

+0

影付きのjarを作成してすべての依存関係を含めることもできます。それを行う方法があり、ここで関連する質問を見つけるでしょう。 – MozenRath

+0

'-cp'は' -jar'で動作しますか? Javaツールの説明から "-jarオプションを使用すると、指定されたJARファイルがすべてのユーザークラスのソースになり、他のクラスパス設定は無視されます。 '-cp'はメインのJARファイルにのみ使用され、他の場所はマニフェストファイルの中で指定されなければなりません。 –

関連する問題