I'm trying to run a JUnit test case from command line using this command:
F:\>java org.junit.runner.JUnitCore org.junit4.9b2.junit.SimpleTest
but I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/JUnitCore
Caused by: java.lang.ClassNotFoundException: org.junit.runner.JUnitCore
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)
Could not find the main class: org.junit.runner.JUnitCore. Program will exit.
What is the problem?
Obviously you need junit on the classpath :-)
java -cp path/to/junit.jar:path/to/local/classes org.junit.runner.JUnitCore \
org.junit4.9b2.junit.SimpleTest
(replace the : with ; on windows platforms)
Related
I've added log4j-api-2.13.0.jar:log4j-core-2.13.0.jar to CLASSPATH but still I get the following error. Any idea how to resolve the error?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at demo.selenium.IBanTest.<clinit>(IBanTest.java:22)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
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
ENV:
CLASSPATH=".:selenium-chrome-driver-3.12.0.jar:selenium-server-standalone-3.13.0.jar:guava-13.0.1.jar:junit4.jar:log4j-api-2.13.0.jar:log4j-core-2.13.0.jar"
BASH:
java demo.selenium.IBanTest
Figured it out.
I also had to include log4j2-2.3.jar.
log4j-core-2.14.1.jar
log4j2-2.3.jar
log4j-api-2.14.1.jar
CLASSPATH for example would be like:
CLASSPATH = ".:/home/user/:selenium-chrome-driver-3.12.0.jar:selenium-server-standalone-3.13.0.jar:guava-13.0.1.jar:junit4.jar:log4j-core-2.14.1.jar:log4j2-2.3.jar:log4j-api-2.14.1.jar"
And run the program in directory target/classes/:
java demo.selenium.IBanTest
I have created a jar file in eclipse using maven and am able to run a class from the jar file with eclipse. However when I run the following command from the command prompt:
c:\recomendation_engine\recomendation\target>java -classpath recomendation-0.0.1
-SNAPSHOT.jar recomendation.ManageGeneralContent test
I get the following error:
Organization Environment test
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
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 java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at recomendation.ManageGeneralContent.main(ManageGeneralContent.java:52)
I believe that the issue is that the class can not find the mysql driver. However it is in the classpath:
c:\Program Files\Java\jdk1.7.0_60\lib\*;C:\Users\User\.m2\repository\com\google\
guava\guava\18.0-rc1\guava-18.0-rc1.jar;C:\Users\User\.m2\repository\org\slf4j\s
lf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\Users\User\.m2\repository\com\jolbox\bonec
p\0.8.0.RELEASE\bonecp-0.8.0.RELEASE.jar;C:\Users\User\.m2\repository\postgresql
\postgresql\9.1-901-1.jdbc4\postgresql-9.1-901-1.jdbc4.jar;c:\recomendation_engi
ne\recomendation\lib\mysql-connector-java-5.1.6.jar;C:\recomendation_engine\reco
mendation\target\recomendation-0.0.1-SNAPSHOT.jar;
Can you please tell me what I am doing wrong?
You are overriding the CLASSPATH environment variable when you specify the "-classpath" switch on the java command line.
Try running:
c:\recomendation_engine\recomendation\target>java
recomendation.ManageGeneralContent test
Check out: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/java.html
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.
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/
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.