My project is a maven project and i use JDBC - postgres driver to run a few queries in the java program. I used maven-jar-plugin to get an executable jar on maven build. When i run jar as java -jar xyz.jar, I get
"Exception in thread "main" java.lang.ClassNotFoundException: org.postgresql.Driver"
I checked manifest.mf file and I could see postgres in classpath as below:
Class-Path: postgresql-42.1.4.jar
Please favour on resolution. This same code runs well as Java application. It only creates problem when it is a jar file.
Maven-jar-plugin in pom.xml is as below:
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>
com.app.App
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>