How do I know which jar files java program needs to run? - java

Recently I was trying to run 2048 bot (upd: author deleted the project, but created the new one). But it just didn't work. And the developer said that it runs from Intelij IDEA just fine. And yes, it appeared it does. So what I did:
>"c:\Program Files\Java\jdk1.7.0_51\bin\javac.exe" Program.java -cp selenium-java-2.41.0.jar
Note: Program.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
>java Program -cp selenium-java-2.41.0.jar
Error: Could not find or load main class Program
Intelij IDEA runs it this way:
"C:\Program Files\Java\jdk1.7.0_51\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_51\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\zipfs.jar;C:\Users\Yuri\Desktop\2048_bot\2048_Bot_2.0-master\target\classes;C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.39.0\selenium-firefox-driver-2.39.0.jar;C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\2.39.0\selenium-remote-driver-2.39.0.jar;C:\Users\Yuri\.m2\repository\cglib\cglib-nodep\2.1_3\cglib-nodep-2.1_3.jar;C:\Users\Yuri\.m2\repository\org\json\json\20080701\json-20080701.jar;C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-api\2.39.0\selenium-api-2.39.0.jar;C:\Users\Yuri\.m2\repository\com\google\guava\guava\15.0\guava-15.0.jar;C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpclient\4.3.1\httpclient-4.3.1.jar;C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpcore\4.3\httpcore-4.3.jar;C:\Users\Yuri\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\Yuri\.m2\repository\commons-codec\commons-codec\1.6\commons-codec-1.6.jar;C:\Users\Yuri\.m2\repository\org\apache\commons\commons-exec\1.1\commons-exec-1.1.jar;C:\Users\Yuri\.m2\repository\net\java\dev\jna\jna\3.4.0\jna-3.4.0.jar;C:\Users\Yuri\.m2\repository\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar;C:\Users\Yuri\.m2\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain Program
Here are the jar files for convenience:
C:\Program Files\Java\jdk1.7.0_51\jre\lib\charsets.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\deploy.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\javaws.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\jce.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\jfr.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\jfxrt.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\jsse.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\management-agent.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\plugin.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\resources.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\rt.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\access-bridge-64.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\dnsns.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\jaccess.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\localedata.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunec.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunjce_provider.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\sunmscapi.jar
C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext\zipfs.jar
C:\Users\Yuri\Desktop\2048_bot\2048_Bot_2.0-master\target\classes
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.39.0\selenium-firefox-driver-2.39.0.jar
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\2.39.0\selenium-remote-driver-2.39.0.jar
C:\Users\Yuri\.m2\repository\cglib\cglib-nodep\2.1_3\cglib-nodep-2.1_3.jar
C:\Users\Yuri\.m2\repository\org\json\json\20080701\json-20080701.jar
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-api\2.39.0\selenium-api-2.39.0.jar
C:\Users\Yuri\.m2\repository\com\google\guava\guava\15.0\guava-15.0.jar
C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpclient\4.3.1\httpclient-4.3.1.jar
C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpcore\4.3\httpcore-4.3.jar
C:\Users\Yuri\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar
C:\Users\Yuri\.m2\repository\commons-codec\commons-codec\1.6\commons-codec-1.6.jar
C:\Users\Yuri\.m2\repository\org\apache\commons\commons-exec\1.1\commons-exec-1.1.jar
C:\Users\Yuri\.m2\repository\net\java\dev\jna\jna\3.4.0\jna-3.4.0.jar
C:\Users\Yuri\.m2\repository\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar
C:\Users\Yuri\.m2\repository\commons-io\commons-io\2.2\commons-io-2.2.jar
C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain Program
So it starts with jdk's jar files, then goes the project output directory, then some jar files, which are probably downloaded by Intelij IDEA on its own and it ends with the Intelij IDEA's jar file, which is probably needed for debugging or something along those lines.
So, how do I know which jar files are needed and where do those ~/.m2 files come from?
UPD Here are probably the minimal jar files set to start this program:
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\2.39.0\selenium-firefox-driver-2.39.0.jar
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\2.39.0\selenium-remote-driver-2.39.0.jar
C:\Users\Yuri\.m2\repository\org\json\json\20080701\json-20080701.jar
C:\Users\Yuri\.m2\repository\org\seleniumhq\selenium\selenium-api\2.39.0\selenium-api-2.39.0.jar
C:\Users\Yuri\.m2\repository\com\google\guava\guava\15.0\guava-15.0.jar
C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpclient\4.3.1\httpclient-4.3.1.jar
C:\Users\Yuri\.m2\repository\org\apache\httpcomponents\httpcore\4.3\httpcore-4.3.jar
C:\Users\Yuri\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar
C:\Users\Yuri\.m2\repository\org\apache\commons\commons-exec\1.1\commons-exec-1.1.jar
So it's not all the jar files even in m2 diretory.
UPD Selenium Client & WebDriver Language Bindings comes with additional jar files but not all of them are needed. So one of the options was to specify all these jar files. But I was able to make it work this way:
>java Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/firefox/FirefoxDriver
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.firefox.FirefoxDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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
>java -cp "selenium-java-2.41.0.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:87)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:77)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:65)
at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:262)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 11 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/exec/Executor
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:47)
at org.openqa.selenium.firefox.FirefoxBinary.startProfile(FirefoxBinary.java:96)
at org.openqa.selenium.firefox.FirefoxBinary.clean(FirefoxBinary.java:226)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:91)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.Executor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 11 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;commons-exec-1.1.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/params/HttpParams
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.http.params.HttpParams
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 8 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;commons-exec-1.1.jar;httpclient-4.3.1.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/params/HttpParams
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.http.params.HttpParams
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 8 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;commons-exec-1.1.jar;httpcore-4.3.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 8 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;commons-exec-1.1.jar;httpcore-4.3.jar;httpclient-4.3.1.jar;." Program
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.http.conn.ssl.AbstractVerifier.<init>(AbstractVerifier.java:82)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<init>(AllowAllHostnameVerifier.java:40)
at org.apache.http.conn.ssl.SSLSocketFactory.<clinit>(SSLSocketFactory.java:145)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:48)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:100)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:81)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Program.main(Program.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 15 more
>java -cp "selenium-java-2.41.0.jar;guava-15.0.jar;json-20080701.jar;commons-exec-1.1.jar;httpcore-4.3.jar;httpclient-4.3.1.jar;commons-logging-1.1.1.jar;." Program
UPD Alternatively:
find -name '*.jar' -execdir cp -t ~/path/to/prj {} +

If you compile
javac Program.java
then Program.class will be generated. This must be in your classpath.
java -cp "Program.class;selenium-java-2.41.0.jar"

A Java program does not need any specific jar files to run, but it need the contained classes.
There are various tools and sites to help you find out:
How to find Jar to which an Java class belongs
There are also tools to help you manage those dependencies, like Maven (.m2 is related to it).
The author states that
You will need to install the Selenium dependency somehow, such as by using Maven.
IMHO the project should come with a pom.xml or the jars.

Related

java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext with executable jar

Project runs fine in Eclipse running as an application. When trying to run the jar that is built by Maven I get the following error:
C:\test>java -jar SybaseTest.jar
C:\test>java -jar SybaseTest.jar
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
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)
... 7 more
The jar file contains all of the libraries in the lib directory:
Libraries in the jar file
The manifest file has the library spring-context-4.3.2.RELEASE.jar in the classpath and the other 11 that are Maven dependencies.
Class-Path: . lib/spring-jdbc-4.3.2.RELEASE.jar lib/spring-beans-4.3.2
.RELEASE.jar lib/spring-core-4.3.2.RELEASE.jar lib/spring-tx-4.3.2.RE
LEASE.jar lib/spring-context-4.3.2.RELEASE.jar lib/spring-aop-4.3.2.R
ELEASE.jar lib/spring-expression-4.3.2.RELEASE.jar lib/commons-dbcp-1
.4.jar lib/commons-pool-1.6.jar lib/jconn4-7.0.jar lib/bcprov-jdk15on
-1.56.jar lib/commons-logging-1.2.jar
Any advice?

Java - JOGL deploy: NoClassDefFoundError

Dev env: ItelliJ 14 -> compiles and runs fine.
When executing my custom created .jar from command line this appears
C:\Java\Projects\OpenGLES\out\artifacts\Test1>java -jar Test1.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/opengl/G
ventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLEventListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 13 more
I'm trying to create .jar artifact, that I could just double click start.
I think that the problem means that this class cannot find some resources. The JOGL/JogAmp official sites gives explanation on deployment of .jars with JOGL, but I think that I missed something.
The Test1.jar has following structure:
Test1.jar/
--com/
----company/
------Main.class
--jar/
----gluegen-rt.jar
----gluegen-rt-natives-windows-amd64.jar
----gluegen-rt-natives-windows-i586.jar
----jogl-all.jar
----jogl-all-natives-windows-amd64.jar
----jogl-all-natives-windows-i586.jar
--lib/
----windows-amd64/
-------gluegen-rt.dll
-------joal.dll
-------jocl.dll
-------jogl_cg.dll
-------jogl_deskop.dll
-------jogl_mobile.dll
-------nativewindow_awt.dll
-------nativewindow_win32.dll
-------newt.dll
-------soft_oal.dll
--META-INF/
----MANIFEST.MF
--com
--jar
--lib
--META-INF
manifest.mf contains -
Manifest-Version: 1.0
Main-Class: com.company.Main
By the stack trace it seems that the JVM cannot find the class com.jogamp.opengl.GLEventListener that means it can't resolve the path to the included jar files. The path of the jar files is not correct. Follow the link to see how to package jars correctly.
https://docs.oracle.com/javase/tutorial/deployment/jar/

Run multiple jar files from batch file one by one

I've exported my Java projects into a runnable jar file with the libaries combined in another folder. I'm trying to the first one to run, when it finishes the second one starts, etcetera. Right now this is what my batch file looks like:
java -jar "C:\path-to-project1.jar" parameter /wait
java -jar "C:\path-to-project2.jar" parameter /wait
java -jar "C:\path-to-project3.jar" parameter /wait
java -jar "C:\path-to-project4.jar" parameter /wait
java -jar "C:\path-to-project5.jar" parameter /wait
However I'm getting the noclassdeffounderror. The only class I'm using in the projects is the main class, which is called "Main.java". It also says " a jni error has occurred. please check your installation and try again".
Should I also call the .lib files or am I missing something else?
This is what the cmd prompts:
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-3-172-Heiniken music hall.jar" main parameter /wait
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/N
oSuchElementException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.NoSuchElementEx
ception
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)
... 7 more
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-3-293-Roode Bioscoop.jar" main parameter /wait
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/N
oSuchElementException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.NoSuchElementEx
ception
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)
... 7 more
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-4-223-Krakeling.jar" main parameter /wait
LOOP EC=2 EH=1 -----------------------------------------------------------------
--------------------------------
While 1 ------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: Functions
at Main.main(Main.java:250)
Caused by: java.lang.ClassNotFoundException: Functions
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 don't know whethere there are more bugs in the code but one is the location of /wait. Try start /wait java -jar "C:\path-to-project1.jar" parameter instead.

Getting java.lang.NoClassDefFoundError on windows 8

When I am trying to run a jar file by giving the following command
java -Xmx500m -jar ap.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
I am getting the following error. I am using windows 8
Throwable Error: java.lang.NoClassDefFoundError: org/supercsv/prefs/CsvPreference
Exception in thread "main" java.lang.Error: java.lang.NoClassDefFoundError: org/supercsv/prefs/CsvPreference
at bc.c.Util.process(Util.java:135)
at bc.m.TabularReader$CSVReader.<init>(TabularReader.java:68)
at bc.m.TabularReader.<init>(TabularReader.java:37)
at bc.c.Spread2db.main(Spread2db.java:244)
Caused by: java.lang.NoClassDefFoundError: org/supercsv/prefs/CsvPreference
at bc.m.TabularReader$CSVReader.<init>(TabularReader.java:64)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.supercsv.prefs.CsvPreference
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 3 more
Please help me resolving this exception.
What you need is to download the SuperCSV jar and also place it on your classpath.
http://sourceforge.net/p/supercsv/news/2014/04/super-csv-220-released/
The library you're using (ap.jar) is referring to this other SuperCSV library.
So you need the SuperCSV jar on your classpath too.
http://sourceforge.net/projects/supercsv/files/

LibreOffice SDK bootstrap

I got the standard jar files + juh-2.4.1.jar and ridl-3.2.1.jar (got errors on import) as referenced libraries in my project. When i get an example piece of code from http://api.libreoffice.org/examples/DevelopersGuide/examples.html#FirstSteps i always land on this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/star/comp/loader/JavaLoader
at com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(Bootstrap.java:118)
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:241)
at TextDocuments.getRemoteServiceManager(TextDocuments.java:410)
at TextDocuments.storePrintExample(TextDocuments.java:378)
at TextDocuments.runDemo(TextDocuments.java:152)
at TextDocuments.main(TextDocuments.java:142)
Caused by: java.lang.ClassNotFoundException: com.sun.star.comp.loader.JavaLoader
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 6 more
Always a NoClassDefFoundError on bootstrap.. Searching for this but can't find much.. Anybody has an idea how to fix this?
In my LibreOffice installation the missing class is located in the file jurt.jar

Categories