Link to home
Start Free TrialLog in
Avatar of delphi3
delphi3

asked on

Adding a junit.jar

Hi All,
I have JBuilder 5, Win2K with NT.

I have a junit.jar that I want to add it to the JB5 so that I can start the program with


import junit.framework.TestCase;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
.............


where in what folder do I place the junit.jar  and what additional settings are needed inorder to make it be seen?


Thanks.

Delphi3

Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

AFAIK with JB you need to add the jar to the project
Look in Project>Properties>Paths
ASKER CERTIFIED SOLUTION
Avatar of GrandSchtroumpf
GrandSchtroumpf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of delphi3
delphi3

ASKER

GrandSchtroumpf,
Wow!!! on this topic you seem very well versed. Do you have JBuilder X Foundation, or the

real JBuilder X?

3 weeks ago I had  the Foundation. It was so big that it overstuffed my computer to the
point that it took 90 seconds to load, and another 90 seconds to run a simple program.
There was no going back to a lighter version other than the JB5 that I have on disk.
But in that version the editor is "poor" x 3. So I looked for a lightweight editor and came up

with DRJava. DRJava is really pretty good but it uses the testcase scenario from Juint.org.
But the latest version 3.8.1. or what ever it is comes to me from sourceforge as a zip file

that will not extract to files other than all files are zero size.  
So I dug around in the internet archives and came up with a version 3.2.

That is where I am now. AND JB5 does not seem to like the junit 3.2.

As per your instructions.... I made the library, and added it to the project.

Now I do get the jbuilder options available in the drop down choices of constructing the line 2

below.

package calculating;
import junit.framework.TestCase;

public class CalculatorTest extends TestCase {

  public void testAddition() {
    Calculator calc = new Calculator();
    // 3 + 4 = 7
    int expected = 7;
    int actual = calc.add(3, 4);
    assertEquals("adding 3 and 4", expected, actual);
  }

  public void testDivision() {
    Calculator calc = new Calculator();
    // Divide by zero shouldn't work
    try {
      calc.divide(2, 0);
      fail("Should have thrown an exception!");
    }
    catch (ArithmeticException e) {
      // Good, that's what we expect
    }
  }

}    


BUT  I get these errors.
"CalculatorTest.java": Error #: 300 : constructor TestCase() not found in class

junit.framework.TestCase at line 4, column 8
"CalculatorTest.java": Error #: 300 : class Calculator not found in class

calculating.CalculatorTest at line 7, column 5
"CalculatorTest.java": Error #: 300 : class Calculator not found in class

calculating.CalculatorTest at line 7, column 27
"CalculatorTest.java": Error #: 300 : class Calculator not found in class

calculating.CalculatorTest at line 15, column 5
"CalculatorTest.java": Error #: 300 : class Calculator not found in class

calculating.CalculatorTest at line 15, column 27

 
AND still DRJava still does not accept this junit.

I do appreciate your detailed help. Only I wish I could say it worked.
Well, it did up to a point.

Delphi3

 
You are referring to a class called Calculator. This must be present in the same package.

(or imported if not in the same package)
for your compiling error with the Calculator, CEHJ already gave the answer.

>  JBuilder X Foundation, or the real JBuilder X?
I have the fake one, the one that gives you tips at startup for features that are only available in the professional version :°).  You definitely need a decent machine with at least 512 RAM to run such IDE comfortably.
I still think that nothing beats a good plain text editor (with sytax highlight) and a good command line.
Avatar of delphi3

ASKER

CEHJ
you wrote:
You are referring to a class called Calculator. This must be present in the same package.

This is confusing, in JB5 operation, it eventually places all parts into the package calculating.  BUT there is no class file made until the CalculatorTest.java file compiles correctly, and in this case it does not compile  into the class file because of the errors indicated above.

Then I guess that I do not understand the wonders of junit.

D3







 
Where is your Calculator class defined?
It won't compile *until* a class called Calculator (not CalculatorTest) or the source file of that class has been made available to the compilation of CalculatorTest
> I still think that nothing beats a good plain text editor (with sytax highlight) and a good command line.

agreed :)
Avatar of delphi3

ASKER

Hi All,
I am quite confused and this is going no where.
 
I did add the junit to JB5 as instructed by GrandSchtroumpf.
 
Then there is the matter of
the sample provided above is poorly constructed. I should have corrected it but I do not know how to.

The sample has java "words" that are not in the to JB5 vocabulary, like "assertEquals". I have tried to make changes to make it possible to show some output. But still it is a piece of confusion as to what it is supposed to do.

An also the issue of trying to get 2 different
tools to work together, JB5 and DRJava.

For the record here,unless someone willing to help further, this will have to go to something worth nothing file.

D3

BTW DRjava is a freebe, is an editor has accepted all of my previously written XXX.java files. It includes: Syntax Coloring, Automatic Indentation, Brace Matching,Commenting / Uncommenting,Line Numbering. Viewing Compiler Errors. But cannot run (test) the programs.

I cannot get it to accept Junit, even though it claims to. And this is what the Q was mostly about.

D3
>>For the record here,unless someone willing to help further, this will have to go to something worth nothing file.

Well since you've already accepted an answer from one person (despite being helped by several) you will have to post a new question
Which j2se version are you running with JB5?
When JB installs, it installs a JDK inside a sub-folder of the JB install folder.
(if you install JB in C:\JBuilderX, the JDK installs in C:\JBuilderX\jdk1.4).
By default, JB will use that JDK... which might be a little obsolete in JB5.
You can change the JDK that JB uses by going to the menu:  "Tools/Configure JDKs"
There you can change the "JDK home path" to your own JDK installation (like j2se1.4).