Results 1 to 6 of 6
  1. #1
    GaloDoido is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

    Default My application java / maven / swing does not run out of netbeans.

    I have a java swing application, built from a maven project in netbeans 8. So, when I run the app inside NB, everything happens like expected. But when I run out from NB, a NoClassDefFoundError exception is fired.

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException
    
    My 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>
        <groupId>br.com.xyz</groupId>
        <artifactId>XYZ</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.7</maven.compiler.source>
            <maven.compiler.target>1.7</maven.compiler.target>
        </properties>
    
        <name>XYZ</name>    
    
        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.6</version>
              <configuration>
                <archive>
                  <manifest>
                    <addClasspath>true</addClasspath>
                    <mainClass>br.com.xyz.gui.swing.JFramePrincipal</mainClass>
                  </manifest>
                </archive>
              </configuration>
            </plugin>
          </plugins>
        </build>    
    
        <dependencies>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.35</version>
            </dependency>
    
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>eclipselink</artifactId>
                <version>2.5.2</version>
            </dependency>
    
            <dependency>
                <groupId>net.sf.jasperreports</groupId>
                <artifactId>jasperreports</artifactId>
                <version>6.1.0</version>
            </dependency>
    
            <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
            </dependency>
    
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
                <version>2.5.2</version>
                <scope>provided</scope>
            </dependency>
    
        </dependencies>
    </project>
    What can be wrong?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: My application java / maven / swing does not run out of netbeans.

    If you have a problem with running an application, it is rather important to detail how you run it. Start with the exact command that you use (assuming by "outside of Netbeans" you mean running from the command prompt/shell).
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    GaloDoido is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

    Default Re: My application java / maven / swing does not run out of netbeans.

    Sure, the command via dos prompt is:
    java -jar D:\...\MyProject-1.0-SNAPSHOT.jar

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: My application java / maven / swing does not run out of netbeans.

    Try running that command INSIDE the directory where the jar is stored so you only have to run

    [noformat]
    java -jar MyProject-1.0-SNAPSHOT.jar
    [/noformat]

    Does that work? If not then something is going wrong generating the jar; more notably something goes wrong generating the jar's manifest as the class-path line that is in there is incorrect.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    GaloDoido is offline Member
    Join Date
    Jul 2015
    Posts
    3
    Rep Power
    0

    Default Re: My application java / maven / swing does not run out of netbeans.

    No, the same message:
    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: My application java / maven / swing does not run out of netbeans.

    Well time to investigate the generation of the jar then. Open it up, see what's in the meta-inf/manifest.mf file. Probably the class-path line is either missing or the path entries in it are incorrect.

    This is an example of what should be there:

    https://docs.oracle.com/javase/tutor...r/downman.html
    Last edited by gimbal2; 07-16-2015 at 04:35 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 3
    Last Post: 01-25-2013, 01:40 PM
  2. Replies: 0
    Last Post: 07-26-2011, 04:34 PM
  3. Replies: 0
    Last Post: 07-19-2010, 10:25 PM
  4. Maven src and netbeans
    By sylph in forum NetBeans
    Replies: 1
    Last Post: 12-17-2009, 06:38 PM
  5. Replies: 3
    Last Post: 12-04-2009, 12:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •