File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes JUnit installation problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "JUnit installation problem" Watch "JUnit installation problem" New topic

JUnit installation problem

hesham katon
Ranch Hand

Joined: Dec 18, 2002
Posts: 82
Hello all friends,
I have a problem with installation of Junit
I've done this job :
- Downloaded Junit , unziped it , put it under : c:\junit3.8.1
- in my windows xp , i've added a new entry in "environment variable"
entry name : CLASSPATH value : c:\junit3.8.1\junit.jar
- i tried to run sample test using the dos prompt
C:\junit3.8.1>java junit.textui.TestRunner junit.samples.AllTests

I get this result :
'java' is not recognized as an internal or external command,
operable program or batch file.
i think it may be a simple problem concerning with classpath , but it really took alot of time from me .
i really appreciate any help
Thanks in advance

Hesham Katon<br />SCJP 1.2<br />SCWCD 1.4<br />Better to light a candle than to curse the darkness
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You haven't correctly set the PATH variable on your XP box. Once you do that you shouldn't have any problems. You need to include your "bin" directory of your J2SE installation in it.

hesham katon
Ranch Hand

Joined: Dec 18, 2002
Posts: 82
dear Nathaniel,
I am really thankful for your reply .
I've tried to add j2se path , but i think i am still do it in the wrong way .
I made it like this :
in the system variable section :
variable name : CLASSPATH
variable value : c:\j2sdk1.4.2_03\bin;c:\junit3.8.1\junit.jar
and this still doesnt work .
i wish you can tell me exactly what is the wrong in the classpath
thank you very much
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You are confusing your classpath with your executable path. One is a Java issue; one is a Windows XP issue. The two are different.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

Also note that the problem is with java, not junit. As recommended above, check that java is in your PATH environment variable.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
hesham katon
Ranch Hand

Joined: Dec 18, 2002
Posts: 82
Thank you very much .
I think i've solved the problem with java path
but i am still have another problem .
Now when i am trying to run this code :
java junit.textui.TestRunner junit.samples.AllTests
i got this result :
Class not found "junit.samples.AllTests"
i think this is related with junit not java path , right ?
I have already added junit to the CLASSPATH like this :
isn't this right ?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
The reason why the JVM doesn't find the "junit.samples" stuff is that those packages are not inside the junit.jar file.
In my JUnit 3.8.1 distribution, those classes are located in "C:\apps\junit-3.8.1\junit\samples\AllTests.class". In other words, you need to add the "C:\apps\junit-3.8.1" directory as an entry into your classpath.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
hesham katon
Ranch Hand

Joined: Dec 18, 2002
Posts: 82

this is finally done
i want to thank all of you very much
Thanks to Nathaniel Stoddard , Jeanne Boyarsky , & Lasse Koskela
your replies were really helpful
Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
I have also setup junit for the first time, and my rekated environment variables are:


JUNIT_HOME = C:\junit3.8.1

Path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Perforce

and now i am able to run


but not:


Any ideas ?

Ariel Valentin
Ranch Hand

Joined: Jan 30, 2004
Posts: 44
If I were you guys, I would use a build tool like ant or an IDE like Eclipse (which has junit built in) to run the examples, instead of using cmd line.
Trying to clean up your PATH and CLASSPATH variables that WIN XP sets is a pain. You may find that every java app server (and even applications) you install has its own JVM and resets those variables. Just use the tools!

A. Valentin
SOK Pongsa Metrey SOK

Joined: Jul 27, 2006
Posts: 2
Thanks very much,
Coz of your chatting, I also can configure my JUnit 3.8.1 that the program was the same, now it is fixed.

Thanks for all your detail.

Hope to have more discuss together,

Mr. Metrey,
I agree. Here's the link:
subject: JUnit installation problem
jQuery in Action, 3rd edition