When I wrote a standalone client and tried to execute it,
it's giving me the following errors:
Running in Windows:
Exception in thread "main" java.lang.NoClassDefFoundError: TestClient
Caused by: java.lang.ClassNotFoundException: TestClient
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: TestClient. Program will exit.
This is in Linux
Exception in thread "main" java.lang.NoClassDefFoundError: TestClient (wrong name: com/tata/bayer/service/TestClient)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TestClient. Program will exit.
Now i am getting
C:\Softwares\apache-tomcat-6.0.33\webapps\tkweb-ws-12.0\WEB-INF\classes\com>java com.tata.bayer.service.TestClient
Exception in thread "main" java.lang.NoClassDefFoundError: com/tata/bayer/service/TestClient
Caused by: java.lang.ClassNotFoundException: com.tata.bayer.service.TestClient
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: com.tata.bayer.service.TestClient Program will exit.
It looks like you should be running
java com.tata.bayer.service.TestClient
from a directory containing "com", with an appropriate directory hierarchy eventually leading to TestClient.class.
You haven't shown whether you're compiling this code yourself or whether it's been given to you. If you are compiling it yourself, you should usually organize the source code so that it reflects the package structure too. So you might run:
javac com/tata/bayer/service/*.java
java com.tata.bayer.service.TestClient
Or maybe:
# Keep source and class files separate...
javac -d bin com/tata/bayer/service/*.java
java -classpath bin com.tata.bayer.service.TestClient
If that doesn't help, please provide more details.
Looks like you want to use com/tata/bayer/service/TestClient and not TestClient. Try using the full path.
Related
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.
I have created a Junit class which runs individually. Now for creating a jar file a i have created a different java class in same package. And in that class i have mentioned junit class name as JUnitCore.runClasses(IMageCredit.class);
Manifest file is ok.
when i am running jar file using cmd it is showing following error
Exception in thread "main" java.lang.NoClassDefFoundError: rahul/IMageCredit
at rahul.TestRunner.main(TestRunner.java:11)
Caused by: java.lang.ClassNotFoundException: rahul.IMageCredit
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
I downloaded the opencsv (from http://sourceforge.net/projects/javacsv/files/latest/download) and since then I have been getting this error with all my Java programs
java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
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.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
How can I fix this? I realized I didn't need the opencsv anyway...how can I remove it so that my programs can compile and run as usual? I'm using Eclipse Version: 1.4.2.20120213-0813
You can remove a plugin by going to Help->About (or Eclipse->About on a Mac), choosing installations details, selecting the plugin you wish to remove, and choosing 'Uninstall'.
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
I could not understand this error, the scenario is:
This is the directory structure:
classes/
root/
pkgmain/Cmain.class
pkg1/C1.class
pkg2/C2.class
The problem is when I try to run Cmain file (main() is in this file) from the following path, I get the error:
C:\Ravi\MakingJarFile\classes\root\pkgmain>java Cmain
Exception in thread "main" java.lang.NoClassDefFoundError: Cmain (wrong name: root/pkgmain/Cmain)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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$000(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)
Could not find the main class: Cmain. Program will exit.**
What could be the solution for this problem, Thanks.
You need to provide the fully qualified class name, and do it from the root directory (or put that directory in the classpath):
C:\Ravi\MakingJarFile\classes> java root.pkgmain.Cmain
or
C:\Anywhere> java -cp C:\Ravi\MakingJarFile\classes root.pkgmain.Cmain
You're telling the java command the full name of a class, and that's what it's looking for. When it finds a relevant class file it will check that the class within it really does have that fully-qualified name
You have to specify the full path to the class - otherwise java can't find the Class.
java root.pkgmain.Cmain