There is a project written in Java. With a simple Run’e in Intellij Idea, everything works fine.
As soon as I do JAR and launch it in the IDE, it takes ClassnotFoundException
.
Fully error:
exception in thread "main" java.lang.classnotfoundException: org.sqlite.jdbc
at java.net.urlclassLoader $ 1.run (urlclassloader.java:372)
at java.net.urlclassLoader $ 1.run (urlclassloader.java:361)
at java.security.accesscontroller.doprivileged (Native Method)
at java.net.urlclassloader.findclass (urlclassloader.java:360)
at java.lang.classloader.loadclass (classlaader.java:44)
AT Sun.Misc.Launcher $ appclassloader.loadclass (launcher.java:308)
at java.lang.classLoader.loadclass (classloader.java: 07)
at java.lang.class.Forname0 (Native Method)
at java.lang.class.Forname (class.java:260)
at com.fruitmix.trashbox.firstsqliteEditor.conn (firstSqliteEditor.java:19)
at com.fruitmix.trashbox.firstsqliteeditor.start (firstSqliteEditor.java:10)
at com.fruitmix.trashbox.clientruler.main (clientruler.java:
19 stitching in FirstSqLiteEditor:
class.forname ("org.sqlite.jdbc");
Driver itself is registered in manifest.mf:
class-path: libs / sqlite-jdbc-3.7.2.jar
How can I fix the error?
Answer 1, Authority 100%
The fact is that the IDEA has its own built-in Manifest
and during startup it lists all .jar
files that should participate in the program. .jar
Files do not contain all libraries that are needed for the program (unlike .war
and .ear
). Therefore, you need to use Manifest
and provide access to libraries when you start .jar
file.
Answer 2, Authority 25%
figured out. Maybe someone will be useful.
- We go to create a new artifact (
Project Structure
= & gt;Artefacts
). - click on “+”, choose jar.
-
Next,
from modules with dependencies
. -
drops the menu, select “
Extract to the target jar
“.
The manifest is created later, and everything works.