Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Junit installation Classpath problem  RSS feed

 
andrew beales
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have been trying to install junit to my classpath through adding junit.jar to my ext folder of jdk. When I command a simple call to java junit.swingui.TestRunner I get cannot not find main noDefintionClassFound.
C:\J2EE\wiley\JavaOpSourPro\examples\examples\chapter03> java junit.swingui.TestRunner Exception in thread "main" java.lang.NoClassDefFoundError: junit/swingui/TestRunner Please use html tags to format code blocks.

I also tried deleting it form the ext ext folder then and putting it the classpath variable of enviromental settings,with the samme error.I then tried just putting the jar in the same folder and using the classpath command argument

java -cp junit-3.8.1.jar junit.swingui.TestRunner This worked what can be my problem with classpath,I am using Microsoft Home.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this thread to the Java in General (Beginner) forum since it's purely a classpath issue with little to do with testing.

Please continue the discussion over there.
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew, did you reboot the system after modifying the ClASSPATH variable? If so, double check if you've set the CLASSPATH correctly. I've encountered the same problem when I tried to put a *.jar file into the ext directory and used Class.forName to load a class from that jar file. Read this article (on top, there's a pdf version) if you want know why weird thing happens when Class.forName is called within ext.

Joyce
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also tried deleting it form the ext ext folder then and putting it the classpath variable of enviromental settings,with the samme error.

What did you do to set the CLASSPATH variable value? Exactly what value did you use? Exactly what name did you specify for the environment variable?

What's the result of running the following command?

echo %CLASSPATH%
 
andrew beales
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally I got junit to work ,to show the swing gui.When I run the testclass public class TestCsvParser extends TestCase from the test class name by pressing Run.
I get : Class not found "TestCsvParser".When I open the navigator through the button with ... symbol I get the No Test class found Check that the configured "TestCollector" is supported on this platform.

Why is this? I also run the test through ant using the preconfigured test task.It works as it should from my book. What can I do with this?

thanks for asking here is my CLASSPATH variable. C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\TOOLS\log4j-1.2.8.jar;C:\TOOLS\maven-java-plugin-1.4.jar;C:\TOOLS\junit3.8.1\junit.jar;C:\TOOLS\hibernate2.jar;C:\TOOLS\commons-beanutils-1.6.1.jar;C:\TOOLS\commons-collections-2.1.jar;C:\TOOLS\commons-digester.jar;C:\TOOLS\commons-lang-1.0.1.jar;C:\TOOLS\commons-logging-1.1-dev.jar;C:\TOOLS\cglib.jar;C:\TOOLS\odmg.jar;C:\TOOLS\dom4j.jar;C:\TOOLS\xml-apis.jar;C:\TOOLS\hsqldb.jar;

I am using Microsoft Home.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Without thinking too hard...)

I notice that your CLASSPATH doesn't include the current working directory, as specified by a period. What happens if you add the current working directory to your CLASSPATH?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!