2016-06-23 4 views
0

libフォルダに依存するjarファイルを持つjarファイルを作成しました。作成したjarをライブラリとして使用しようとすると、「スレッド内の例外」メインの「java.lang.NoClassDefFoundError」のように表示されます。すべての必要な瓶を最終的な瓶に入れる方法は?

従属するjarを持つjarファイルを作成するのに助けてくれる人はいますか?

ありがとうございます。ここで

は私のpom.xmlです: `

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <properties> 
     <jclouds.version>1.9.2</jclouds.version> 
    </properties> 
    <groupId>org.apache.jclouds.examples</groupId> 
    <artifactId>openstack-examples</artifactId> 
    <version>1.0</version> 
    <build> 
     <plugins> 
     <!-- any other plugins --> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.1</version> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <!-- this is used for inheritance merges --> 
        <phase>package</phase> 
        <!-- append to the packaging phase. --> 
        <goals> 
        <goal>attached</goal> 
        <!-- goals == mojos --> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     </plugins> 
    </build> 
</project> 

これは私のjarファイル内のMANIFESTの内容です:あなたはmaven shade jarにを使用することができます

Manifest-Version: 1.0 
Archiver-Version: Plexus Archiver 
Built-By: root 
Created-By: Apache Maven 3.3.9 
Build-Jdk: 1.8.0_25 

Here I add the image for structure of my jar file.

+0

mavenを使用していますか?それは非常に簡単です。 –

+0

'lib'のjarファイルをクラスパスに入れる必要があります。 – Sanjeev

+0

あなたはそれを見ることができます。 https://www.youtube.com/watch?v=BsndjGOc1w4 – Rafiq

答えて

1

uber jarを作成します。

また、1つのjarを作成する代わりに、JARSを含むフォルダのパスを指定することもできます。参照: - Run a JAR file from the command line and specify classpath

何かがjava -cp "jar_name.jar;libs/*" com.test.Appのように動作するはずです。

+0

私は4つのクラスと20種類の依存するjarファイルを4つのクラスファイルに持っていますが、これらは4つのクラスと依存jarsを含むjarファイルを作成する必要があります。私のjarファイルは、実行可能なjarではなくライブラリjarとして使用されます。 –