I have this code:
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
try{
FirefoxDriver driver = new FirefoxDriver();
driver.get("http:\\www.yahoo.com");
} catch(Exception e){
e.printStackTrace();
}
}
}
and I want to run it in cmd. For this reason I call the following commands in a .bat file.
javac -classpath "C:\selenium-2.42.2\selenium-server-standalone-2.42.2.jar;C:\selenium-2.42.2\selenium-java-2.42.2.jar;C:\selenium-2.42.2\selenium-firefox-driver-2.42.2.jar" Test.java
java Test
The following error is returned:
C:\selenium-2.42.2>javac -classpath "C:\selenium-2.42.2\selenium-server-standalo
ne-2.42.2.jar;C:\selenium-2.42.2\selenium-java-2.42.2.jar;C:\selenium-2.42.2\sel
enium-firefox-driver-2.42.2.jar" Test.java
C:\selenium-2.42.2>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/f
irefox/FirefoxDriver
at Test.main(Test.java:6)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.firefox.Firefox
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)
... 1 more
Also, the following information will help:
java -versiongot:java version "1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
C:\Program Files (x86)\Mozilla Firefox>firefox.exe -v | more Mozilla Firefox 30.0
Maybe this post will marked as duplicate but I followed others suggestions without any success. Can you please cast some light the situation?
Here is the jar files I use.
Thanks!
PS: Win7 64bit
WebDriver driver = new FirefoxDriver();.jarfiles, cmd returns similar error:the Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/W ebDriver. Strange again. Is anything wrond injarfile loading?