我正在尝试使用 shell 命令在 Jenkins 上运行 Java Selenium 代码。Java 文件需要 3 个.jar
文件才能运行。我厌倦了,除其他命令外,Javac "*.jar" myfile.java
不起作用。
我正在从存储库中提取代码,并且主节点正在运行 RedHat 6。当我运行javac myfile.java
时,我收到以下错误消息:
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)
ClusterReloadAut.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^
ClusterReloadAut.java:5: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^
ClusterReloadAut.java:6: error: package org.openqa.selenium.firefox does not exist
import org.openqa.selenium.firefox.FirefoxDriver;
^
ClusterReloadAut.java:11: 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
要将myfile.java
编译为myfile.class
(以便您可以使用java
命令运行它),您需要向javac
命令添加-cp path/to/selenium.jar
。喜欢这个:
javac -cp path/to/selenium.jar myfile.java
Javac是java编译器,java是用于运行java程序的命令。这可能是原因吗?
你看到任何错误吗?