最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

java - JAR cannot find a suitable driver for SQLite JDBC connection even though it is in the classpath - Stack Overflow

matteradmin6PV0评论

Let me begin by saying that I've gone through half a dozen questions with the same subject and through the answers that tell to add SQLite JDBC driver to the pom.xml file. My case is different, because the dependency is already there and has always been, since the creation of the project. It runs in Netbeans but does not run on the command line.

Here's my pom. I removed other dependencies that have no bearing on the question and left only Xerial:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0" xmlns:xsi="; xsi:schemaLocation=".0.0 .0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.my</groupId>
    <artifactId>myproj</artifactId>
    <version>1.0-0</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.my.myproj.myclass</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mavenpiler.source>11</mavenpiler.source>
        <mavenpiler.target>11</mavenpiler.target>
        <exec.mainClass>com.my.myproj.myclass</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
          <groupId>.xerial</groupId>
          <artifactId>sqlite-jdbc</artifactId>
          <version>3.46.0.1</version>
        </dependency>
    </dependencies>
    <name>myproj</name>
    <description>myproj is</description>
</project>

Here's my manifest. I also removed the irrelevant dependencies from the classpath:

Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 11
Class-Path: <some jars> sqlite-jdbc-3.46.0.1.jar slf4j-api-1.7.36.jar <more jars>
Main-Class: com.my.myproj.mymainclass

I do notice that slf4j is in the classpath but not in pom.xml but this should not be a problem, should it? If it's on the classpath, that should suffice, should it not?

What is still missing for this JAR to be self-contained and run on the command line?

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far