0

I am unable to execute selenium tests(JUNIT) from command line

my project folder path class file

C:\Users\CP042756\workspace\BLR_demo1\bin\com\analytics\logindash 

File :LoginTest.class

my project folder path java file

C:\Users\CP042756\workspace\BLR_demo1\src\com\analytics\logindash

File:LoginTest.java

jar file folder: C:\jars\imp\selenium-2.45.0\libs

jar fiLe: junit-dep-4.11.jar

it runs properly in Eclipse

i want to run it in command line

i have tried the following commands from the command line

1)
java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar:C:\Users\CP042756\workspace\BLR_demo1\bin\com\analytics\logindash org.junit.runner.JUnitCore LoginTest

Error:Could not find or load main class

2)java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar org.junit.runner.JUnitCore LoginTest 

Error:Could not find class:Login test Exception in thread main java.lang.noclassdefounderror

Please help,

Chaitanya Pujari
  • 367
  • 4
  • 16

1 Answers1

0

You have to use semicolon as path separator in Windows. Then your first example should work.

For class files there are two different rules. check, which one applies to your situation:

For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).

So, for the latter try this:

java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar;C:\Users\CP042756\workspace\BLR_demo1\bin org.junit.runner.JUnitCore com.analytics.logindash.LoginTest
Würgspaß
  • 4,660
  • 2
  • 25
  • 41
  • yes tried but Error:Could not find class:Login test Exception in thread main java.lang.noclassdefounderror – Chaitanya Pujari Jun 18 '15 at 11:44
  • yes i did some research on that don't no where i am missing stuck up badly and tried like this same error java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar;C:\Users\CP042756\workspace\BLR_demo1 org.junit.runner.JUnitCore LoginTest Error:Could not find class:Login test – Chaitanya Pujari Jun 18 '15 at 12:06
  • See my answer. **Full package name**: com.analytics.logindash.LoginTest – Würgspaß Jun 18 '15 at 12:08
  • yes i tried that too java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar;C:\Users\CP042756\workspace\BLR_demo1\bin\com\analytics\logindash org.junit.runner.JUnitCore com.analytics.logindash.LoginTest **Error: could not find class com.analytics.logindash.LoginTest ** – Chaitanya Pujari Jun 18 '15 at 12:19
  • See my answer. **class path ends with the directory...** In your case the second cp should end on **bin** not on **logindash** – Würgspaß Jun 18 '15 at 12:22
  • thanks for your help sir. but no help i tried it all 1) java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar;C:\Users\CP042756\workspace\BLR_demo1 org.junit.runner.JUnitCore com.analytics.logindash.LoginTest 2) java -cp C:\jars\imp\selenium-2.45.0\libs\junit-dep-4.11.jar;C:\Users\CP042756\workspace\BLR_demo1\bin org.junit.runner.JUnitCore com.analytics.logindash.LoginTest – Chaitanya Pujari Jun 18 '15 at 12:29