armjafar armjafar - 3 months ago 20
Bash Question

Run Selenium Java Code on Jenkins master using shell

Im trying to run a Java selenium code on Jenkins using shell command, java file needs 3 jar files in order to run

Im using Javac "*.jar"

which is not working

I have tried few other command lines but it doesn't work

Im pulling the code form a repository and the master node is running RedHat 6

If I just use javac

I get the follwoing error

java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode) error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^ error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^ error: package org.openqa.selenium.firefox does not exist
import org.openqa.selenium.firefox.FirefoxDriver;
^ error: cannot access WebDriver
static WebDriver driver = new FirefoxDriver();
bad class file: ./WebDriver.class
class file contains wrong class: org.openqa.selenium.WebDriver
Please remove or make sure it appears in the correct subdirectory of the classpath.
Build step 'Execute shell' marked build as failure
Finished: FAILURE


To compile your into myfile.class (so you can run it with java command) you need to add a -cp path/to/selenium.jar to javac command. Like this:

javac -cp path/to/selenium.jar