I can run my Java program fine in the IDE but when I try this very first step in the command line:
javac Main.java Test.java
then I get a series of errors.The errors are saying all of my imports do not exist
Main.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^
Main.java:4: error: package org.openqa.selenium does not exist
import org.openqa.selenium.Platform;
^
Main.java:5: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^
Main.java:6: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
^
Main.java:7: error: package org.openqa.selenium.remote does not exist
import org.openqa.selenium.remote.DesiredCapabilities;
^
Main.java:8: error: package org.openqa.selenium.remote does not exist
import org.openqa.selenium.remote.RemoteWebDriver;
^
Main.java:16: error: cannot find symbol
DesiredCapabilities caps = new DesiredCapabilities();
^
symbol: class DesiredCapabilities
location: class Main
Main.java:16: error: cannot find symbol
DesiredCapabilities caps = new DesiredCapabilities();
^
symbol: class DesiredCapabilities
location: class Main
Main.java:25: error: cannot find symbol
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
^
symbol: class WebDriver
location: class Main
Main.java:25: error: cannot find symbol
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
^
symbol: class RemoteWebDriver
location: class Main
Main.java:27: error: cannot find symbol
WebElement element = driver.findElement(By.name("q"));
^
symbol: class WebElement
location: class Main
Main.java:27: error: cannot find symbol
WebElement element = driver.findElement(By.name("q"));
^
symbol: variable By
location: class Main
12 errors
What am i Doing wrong? How can I get my code to find these imports correctly?
EDIT: I have looked at the other answers and they are not working for me. All of my jar files are located here C:\Users\NROLL97\Documents\jars
. Here is an example of what I've tried:
javac -cp "C:\Users\NROLL97\Documents\jars\*.jar:." Main.java
For anyone else who might come across this...
Something like this is needed:
java -cp ".\target\classes;lib\*;" org.testng.TestNG ParallelTestXML.xml
.\target\classes
is the path to the class files (not the .java files) and lib\*
is the path to all of my jars
in the lib
folder.
Now all necessary dependencies will be found