I'm having a project in IntelljiIdea, and it's a simple program for visiting some URLs, using selenium. I got this working just fine in python and C# using both Chromium and Firefox, but not in Java.
Here are the libraries from Idea
I'm using the selenium-server-standalone.jar, latest, from http://selenium-release.storage.googleapis.com/index.html?path=2.48/, same as common-codecs, I'm using the standalone jar file, and for selenium-chrome-driver and selenium-firefox-driver, I'm using maven. Firefox works in the IDE, but once I run the jar (artifact), I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
at com.myprogram.controller.VisitController.visit(VisitController.java:109)
at com.myprogram.controller.VisitController.visit_websites(VisitController.java:73)
at com.myprogram.controller.VisitController.run(VisitController.java:45)
at com.myprogram.controller.Controller.visit(Controller.java:127)
at com.myprogram.controller.Controller.run(Controller.java:280)
at com.myprogram.Main.main(Main.java:11)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Only Firefox is working, starting it from the IDE. Chrome (chromium), doesn't work from IDE, and not working started from command line either, same as Firefox, if I start the program with java -jar my_program.jar
I'm on archbang x64, using the selenium version from screenshots, and java version 1.7.0_91
Any suggestions are appreciated.
UPDATE
I have set selenium jar files to be a dependencies in my artifact, so selenium should be included in my_program.jar.
In other words, if I run it like this java -cp selenium-server-standalone-2.48.2.jar -jar my_program.jar
will give me the same error.