mavenpom.xmlclassnotfoundabsolutelayout

No error in netbeans ide but java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout ERROR when java -jar jarfilename.jar


the maven app is running with no error on netbeans ide and the clean and build are running also without errors , the dependencies i didnt mention are :(mongodb,mongodb driver,mysql,itext) i tried launch4j , the .exe file didnt open. this is the POM file :

<?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>
  <groupId>com.mycompany</groupId>
  <artifactId>billing-system</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <repositories>
      <repository>
          <id>unknown-jars-temp-repo</id>
          <name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
          <url>file:${project.basedir}/lib</url>
      </repository>
      </repositories>
  <dependencies>
     <dependency>
  <groupId>org.netbeans.external</groupId>
  <artifactId>AbsoluteLayout</artifactId>
  <version>RELEASE120</version>
</dependency>
  </dependencies>
  <properties>     
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
      <itext.version>7.1.13</itext.version>
  </properties>
<build>
  <plugins>
      <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
      <execution>
          <id>copy-dependencies</id>
          <phase>prepare-package</phase>
          <goals>
              <goal>copy-dependencies</goal>
          </goals>
          <configuration>
              <outputDirectory>
                  ${project.build.directory}/libs
              </outputDirectory>
          </configuration>
      </execution>
  </executions>
</plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
       <version>3.2.0</version>
      <configuration>
        <archive>
          <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
        </archive>
     
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <mainClass>login</mainClass>
          </manifest>
        </archive>
      </configuration>
     
    </plugin>
  </plugins>
</build>
  
</project>

i tried creating a awtextra folder in lib/ and copy absolutelayout folder in it from external/ and it did not work .and this the command line error :

OneDrive\Desktop\billing-system\target>java -jar billing-system-1.0-SNAPSHOT.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout
        at login.initComponents(login.java:41)
        at login.<init>(login.java:21)
 


Solution

  • Problem solved 1.installed maven 2.added configuration to java JAVA_HOME 3.added configuration to maven MAVEN_HOME 4.added plugin with goals to pom file 5.added built with dependencier to jar file 6.used launch4j for an exe file my pom file :

    
     <build>
        <plugins>
            <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>
                        ${project.build.directory}/libs
                    </outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                    <classpathPrefix>lib/</classpathPrefix>
                    <mainClass>login</mainClass>
                </manifest>
            </archive>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
    </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
             <version>3.2.0</version>
            <configuration>
              <archive>
                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
              </archive>
           
              <archive>
                <manifest>
                  <addClasspath>true</addClasspath>
                  <mainClass>login</mainClass>
                </manifest>
              </archive>
            </configuration>
           
          </plugin>
          <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.4.0</version>
      <executions>
            <execution>
                <phase>install</phase>
                <goals>
                    <goal>java</goal>
                </goals>
            </execution>
        </executions>
      <configuration>
        <mainClass>login</mainClass>
      </configuration>
    </plugin>
    
        </plugins>
        
            <defaultGoal>install</defaultGoal>
            <!-- Source directory configuration -->
            <sourceDirectory>src</sourceDirectory>
    
      </build>