質問

I get NoClassDefFoundError at jsoup library trying to run my project jar on other computer. I added jsoup as maven dependency, added in project settings-modules-dependencies, though I get same Exc. I run project via:

java -classpath lostfilm-1.0.jar project.start.Entrance

Please tell me where am I wrong. 4.0.0

<groupId>lostfilm</groupId>
<artifactId>lostfilm</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<modules>
</modules>

<dependencies>
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.7.3</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
</dependencies>
<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>
役に立ちましたか?

解決

Add the JSoup jar file to your classpath

java -classpath lostfilm-1.0.jar;jsoup.jar project.start.Entrance

他のヒント

Add this to your POM:

<build>
<plugins>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.1</version>
   <configuration>
     <mainClass>project.start.Entrance</mainClass> 
   </configuration>
</plugin>
</plugins>
</build>

and then run

mvn exec:java

from the root directory of your project. Running your code this way will pull in all your maven dependencies without adding them to command line.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top