i am a freshman computer science major, studying ahead of the class. we have been using automated testing classes { junit.framework.TestCase; }. i have downloaded junit4.9b2.jar from junit.org, which i understand to be the junit package (?) but i don't know how to use it.

i have read that javac will check { \Java\jdk6\lib\ext\ } for packages, but this doesn't seem to be working.

i have read to append the file name { \Java\jdk6\lib\ext\junit4.9b2.jar; } to "CLASSPATH", but this hasn't worked either.

i have used netbeans, jcreator le, and cmd, all with the result of
{

package junit.framework does not exist
import junit.framework.TestCase;
                      ^

}

i would like to know how to add a package to the packages that javac automatically checks, but i would settle for knowing how to use the package at all.

thanks in advance for any assistance.

This from the junit FAQs may help?

How do I install JUnit?

First, download the latest version of JUnit, referred to below as junit.zip.

Then install JUnit on your platform of choice:

Windows

To install JUnit on Windows, follow these steps:

Unzip the junit.zip distribution file to a directory referred to as %JUNIT_HOME%.
Add JUnit to the classpath:

set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar

I've done this, but i still get that the package doesn't exist. I've rechecked the .jar file to make sure that i'm spelling everything correctly. the only thing i'm not sure about is CLASSPATH.

This is the printout from cmd.

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\System32>cd C:\Java

C:\Java>javac Testing.java
Testing.java:1: package junit.framework does not exist
import junit.framework.TestCase;
                      ^
1 error

C:\Java>echo %CLASSPATH%
.;C:\program files\java\jre6\lib\ext\QTJava.zip;%JUNIT_HOME%\junit-4.8.1.jar

C:\Java>echo %JUNIT_HOME%
C:\program files\java\junit4.8.1

C:\Java>

and this is Testing.java

import junit.framework.TestCase;

class Testing{
}

i'm running windows 7, jre6, and jdk1.6.0_24, if that makes any difference.

How does one typically go about downloading and using a package?
so that maybe i could figure out where i messed up...

Just a guess... but maybe your import statements have the wrong package name? I suspect that should be org.junit...

I've checked the junit FAQ, and you were correct: the import statement does need to have org.junit. However, javac still says that the package does not exist.

C:\Java>javac Testing.java
Testing.java:1: package org.junit.framework does not exist
import org.junit.framework.TestCase;
^
1 error

i had the same problem i had to ad the junit.jar as a global variable

i had the same problem i had to ad the junit.jar as a global variable

If you explain your problem in more details maybe we can help you. In general there are two ways to add JUnit to your project:
1. Manually download JAR and add it to your lib folder in the project
2. Use a tool Like Maven or Gradle to take care of depencies

So which road you wish to go?

PS: In the future I wouldn't be happy for you to re-open old thread. you better create new thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.