简体   繁体   中英

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. I am only able to run the program inside of VS Code using their "Run" feature. 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. It can fetch all the needed dependencies if you have added the maven dependency to the pom.xml file.

Otherwise download the Selenium jar file and use the following command to compile your code.

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

and run the following to execute

java MainClass

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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