Running Selenium via command line java.lang.class.notFoundexception



  • I am trying to run a java file from selenium using cmd. Just adding libraries means that the java command (in command lines) does not work (javac works, the file is compiled). Does anyone know any hint?

    package folder;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.openqa.selenium.support.ui.Select;
    public class fileJava{
      public static void main(String[] args){
        System.out.print("Hello World");
      }
    }
    

    enter image description here



  • You should run your code as

    java folder/fileJava
    

    Here is the test (I had to remove imports since I believe there are some not mentioned conditions specific for your environment)

    C:\tmp>java folder/fileJava.class
    Error: Could not find or load main class folder.fileJava.class
    
    C:\tmp>java folder/fileJava
    Hello World
    C:\tmp>
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2