- Good day to all Gathered a jar without dependencies, running the bat file with the
java -cp maven.jar Main- everything works fine - If I add intellij idea in JSOP project settings. In development environments, everything is working fine.
I have only one class:
import java.io.File; import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; public class Main { public static void main(String[] args) throws IOException { int[] array = {2,5,4,7,8,12,3,4,5,31,1,12}; System.out.print("Privet "); Document doc = Jsoup.connect("http://google.com/").get(); String title = doc.title(); System.out.println(title); } } Which in the development environment is absolutely normal, but after building in jar via the console it answers:
java -cp maven.jar Main Privet Exception in thread "main" java.lang.NoClassDefFoundError: org/jsoup/Jsoup at Main.main(Main.java:14) Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more I can not understand for what reason it can not find the connected libraries, if everything works out perfectly in the development environment
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>asd</groupId> <artifactId>d</artifactId> <version>1.0-SNAPSHOT</version> </project>
pom.xml- Mikhail Vaysman