简体   繁体   English

在源代码中使用 selenium 时,如何从命令行编译 java 程序?

[英]How do you compile a java program from the command line while using selenium in the source code?

I am working on a final project for my Computer Science course.我正在为我的计算机科学课程做一个期末项目。 I built an program using the Selenium library to automate the process of creating a github repo and linking it to a local folder.我使用 Selenium 库构建了一个程序,以自动化创建 github 存储库并将其链接到本地文件夹的过程。 I am only able to run the program inside of VS Code using their "Run" feature.我只能使用它们的“运行”功能在 VS Code 中运行程序。 I want to be able to run this from the Command Line in Windows, but I am not able to compile it since Java doesn't recognize Selenium object types like WebDriver and WebElement. I want to be able to run this from the Command Line in Windows, but I am not able to compile it since Java doesn't recognize Selenium object types like WebDriver and WebElement. How would I compile it using this outside library?我将如何使用这个外部库编译它?

It is strongly recommended to use Maven for java projects.强烈建议将 Maven 用于 java 项目。 It can fetch all the needed dependencies if you have added the maven dependency to the pom.xml file.如果您已将 maven 依赖项添加到 pom.xml 文件,它可以获取所有需要的依赖项。

Otherwise download the Selenium jar file and use the following command to compile your code.否则下载 Selenium jar 文件并使用以下命令编译您的代码。

javac -cp .:jarfile1.jar:jarfile2.jar <MainClass>.java

and run the following to execute并运行以下命令执行

java MainClass java MainClass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM