I am trying to run a Java class with a bat file. I have created the bat file and, as I use selenium related libraries within the class, I added them in a folder and compiled with the help of it. The bat helps me compile, but I cannot run because of "Error: Could not find or load main class src\main\java\com\findyourbet\tennis\automation\CollectData.class Caused by: java.lang.ClassNotFoundException: src\main\java\com\findyourbet\tennis\automation\CollectData.class " I will post below my script and what I have tried.
My script is this:
set projectpath=C:\Users\Mihaaaa\IdeaProjects\tennis
cd %projectpath%
javac -cp lib/*
src\main\java\com\findyourbet\tennis\automation\CollectData.java
My lib is located in C:\Users\Mihaaaa\IdeaProjects\tennis and my class is in the path : C:\Users\Mihaaaa\IdeaProjects\tennis\src\main\java\com\findyourbet\tennis\automation. After running the bat, I tried the following commands, all with the class not found error:
java -classpath . src\main\java\com\findyourbet\tennis\automation\CollectData.class ( from the tennis folder)
java src\main\java\com\findyourbet\tennis\automation\CollectData.class ( from the tennis folder)
java -classpath . com.findyourbet.tennis.automation.CollectData ( from the automation folder and also from other folders as well )
java -classpath . CollectData.java ( from the folder where the class is, automation)
java -cp . com.findyourbet.tennis.automation.CollectData ( from automation folder)
java -cp . CollectData.class ( from automation folder)
None of these worked. Can anyone help me?