私はいくつかのSeleniumテストを実行するためにコマンドラインから実行している.javaファイル(別の開発者によって構築されている)を持っています。
SeleniumsTests.java
/lib (directory of dependencies)
このjavaファイルを端末から直接実行しようとすると、libディレクトリに保存されていないパッケージに関連する一連のエラーが返されます。
SeleniumsTestsjava:21: error: package org.junit does not exist
import org.junit.Assert;
^
SeleniumsTests.java:22: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^
SeleniumsTests.java:23: error: package org.openqa.selenium does not exist
import org.openqa.selenium.Keys;
^
SeleniumsTests.java:24: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
// other similar related errors
以内 。java自体私は次のインポート内でこれらへのリンクを見ることができますが、対応するフォルダ "lib"にどのようにリンクしているのかわかりません - これらのパッケージをこのlibディレクトリに反映するにはどうすればいいですか?
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
回答:
回答№1は1すべてのJavaプログラムに対して、外部のjarファイルに依存する場合は、javaクラスパスに追加する必要があります。のような外部の瓶のための最初のGoogle download jar org.openqa.selenium and org.junit
MavenサイトからダウンロードしてJavaクラスパスに追加してコンパイルしてください javac
のように走る java -classpath "class-path" javaclassfileNamewithoutextension
(.classの拡張子なし): -