Panda
Panda

Reputation: 1

How i can resolve Java.lang.NoClassDefFoundError?

I'm trying to make a jar of a code that i made in maven. But when i try to execute the jar generated by: mvn clean package

I got the following error: rror: Unable to initialize main class <Main_Class> Caused by: java.lang.NoClassDefFoundError: us/hebi/matlab/mat/types/MatFile

I use the import us.hebi.matlab.mat.types.MatFile in my code and i put the dependency in the pom.xml as:

    <dependency>
        <groupId>us.hebi.matlab.mat</groupId>
        <artifactId>mfl-core</artifactId>
        <version>0.5.14</version>
    </dependency>

I can run the code with netbeans and visual studio in my Kali Linux with openjdk 17.0.6 2023-01-17 , but i can't run the jar.

Please someone could help me ?

Greetings.

I try to generate the jar in netbeans and visual studio, but also i try to put the following plugin in the pom.xml.

    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.0.2</version>
      <configuration>
        <archive>
          <manifest>
            <mainClass>MAIN_CLASS</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>

Upvotes: 0

Views: 772

Answers (1)

Ryan Ashcraft
Ryan Ashcraft

Reputation: 1

There are many existing answers for this, such as Why am I getting a NoClassDefFoundError in Java?. As noted there, you'll need to look more deeply at the stack trace and will likely find another error that will help explain things.

Upvotes: 0

Related Questions