1

I was trying to execute a program which is on Desktop from the command line :

javac 'BrowserStackTest.java'

Body of the program:

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
  
import java.net.URL;

public class BrowserStackTest {

}

And I got the below error:

BrowserStackTest.java:1: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.By;
                              ^
BrowserStackTest.java:2: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.Platform;
                              ^
BrowserStackTest.java:3: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.WebDriver;
                              ^
BrowserStackTest.java:4: error: package org.openqa.selenium does not exist
    import org.openqa.selenium.WebElement;
                              ^
BrowserStackTest.java:5: error: package org.openqa.selenium.remote does not exist
    import org.openqa.selenium.remote.DesiredCapabilities;

From the error I was able to observe that I am not providing the jars for the execution, but I am unable to provide them due to lack of enough documentation such as where to add the jars for execution of such programs.

4
  • 1
    Please don't mind that class is empty Commented Feb 21, 2019 at 12:22
  • 1
    use -cp option to specify the jars to include like here stackoverflow.com/questions/25025018/… Commented Feb 21, 2019 at 12:27
  • @Nadir Thanks it worked javac -cp "selenium-2.48.2/selenium-java-2.48.2.jar;selenium-2.48.2/selenium-java-2.48.2-srcs.jar;selenium-2.48.2/libs/*" BrowserStackTest.java But i got some more info after executing with the above Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Commented Feb 21, 2019 at 12:47
  • In Continuation to the above comment upon executing the class java BrowserStackTest Got the below Error Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/Capabilities at java.lang.Class.getDeclaredMethods0(Native Method) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.Capabilities Commented Feb 22, 2019 at 6:56

1 Answer 1

1

I solved this problem by: 1- download selenium jar file from here , name should be like "client-combined-3.141.59.jar"

2-include the jar file in libs folder.

3-in app build.gradle add below line:

implementation files('libs/client-combined-3.141.59.jar')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.