Java程序赢得';编译后无法正常运行

Java程序赢得';编译后无法正常运行,java,maven,dependencies,Java,Maven,Dependencies,我在编程方面是新手,我的第一个程序是利用互联网上的所有资源编写的。因此,我使用NetBeans 11.2使用Maven应用程序制作了Java。当我完成我的程序时,我终于说到了这一点,现在我被卡住了。我试图从命令提示符下运行它,并发出begone命令。首先,我必须处理NoClassDefFoundError:AbsoluteLayout问题。我必须通过将整个项目中的布局更改为NullLayout来修复它。程序最终启动后,我收到另一个错误:com/mchange/v2/c3p0/ComboPoole

我在编程方面是新手,我的第一个程序是利用互联网上的所有资源编写的。因此,我使用NetBeans 11.2使用Maven应用程序制作了Java。当我完成我的程序时,我终于说到了这一点,现在我被卡住了。我试图从命令提示符下运行它,并发出begone命令。首先,我必须处理
NoClassDefFoundError:AbsoluteLayout
问题。我必须通过将整个项目中的布局更改为
NullLayout
来修复它。程序最终启动后,我收到另一个错误:com/mchange/v2/c3p0/ComboPooledDataSource。几天来,我一直在努力寻找答案,但还是没有运气。尝试了所有建议的步骤

  • 检查pom.xml文件-列出的依赖项
  • 选中NetBeans中的库-包括库
  • 为NetBeans重新配置了Maven
  • 使用不同的选项多次清理和重建项目(只需构建、清理和构建,然后继续)
似乎出于某种原因,依赖项不希望加载。
谁能帮帮我吗

多谢各位

<?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>ews.ykotov</groupId>
    <artifactId>TechInfo</artifactId>
    <version>1.0</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>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.18</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>mchange-commons-java</artifactId>
            <version>0.2.19</version>
        </dependency>
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.swinglabs.swingx</groupId>
            <artifactId>swingx-all</artifactId>
            <version>1.6.5-1</version>
        </dependency>
        <dependency>
            <groupId>com.toedter</groupId>
            <artifactId>jcalendar</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.netbeans.external</groupId>
            <artifactId>AbsoluteLayout</artifactId>
            <version>RELEASE112</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>13</maven.compiler.source>
        <maven.compiler.target>13</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>techinfo1.MainPage</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
伊科托夫新闻社

多亏了@Simon,最终解决了这个问题并进入下一阶段。我还必须使用本文()修改pom.xml的文件构建部分。也许有人会觉得它很有用。

将包含
ComboPooledDataSource
的jar添加到您的类路径中。Maven负责构建部分。添加到系统环境的类路径仍然没有帮助。try
java-cp…jar
错误:无法找到或加载主类TechInfo-1.0.jar,原因是:java.lang.ClassNotFoundException:TechInfo-1.0。jar@Yuri,要运行代码,您不仅需要自己的代码,还有您定义为依赖项的所有jar。您可以使用
maven依赖插件
创建包含所有依赖jar的lib目录。然后确保使用
java-cp“TechInfo.jar;lib/*”techinfo1.MainPage将该库包含在类路径中