aspose file tools*
The moose likes Beginning Java and the fly likes Help with error in running program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with error in running program" Watch "Help with error in running program" New topic
Author

Help with error in running program

Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
Here is what I'm doing for this assignment:
Create a class called Rational for performing arithmetic
with factions. Write a driver program to test your class.
Use integer variables to represent the private instance variables
of the class, numerator and denominator. These instance variables
are not changed by any of the methods other than the constructor
method. (Immutable object)
The following methods are part of the class.
/** Constructor that initialized values of rational number */
public Rational(int numerator, int denominator);
/** Add other rational number and this rational number
* and return new Rational number. Do not change this rational
* number.
*/
public Rational add(Rational other);
/** Substract other rational number from this rational number
* and return new Rational number. Do not change this rational
* number.
*/
public Rational subtract(Rational other);
/** Print numerator = ... denominator = ... for this rational
* number.
*/
public void print();
/** Print rational number = xx.xx */
public void printfloat();
------------------------
The test class will be of form:
public class TestRational {
// main
public static void main(String[] args) {
// create and test Rational objects here
}
}
______________________________End of instructions
--------------------------------------------------------------------
Here are my programs
End of Rational.java
End Test Rational.java
They both compile, but when I run the TestRational.java it gives me the following error, and I'm wondering if anyone can help explain what it is. This is only my fourth java program I've written, so I'm really new to Java, and to programming. Any help will be appreciated.
C:\myjava\assignment2\problem1>java TestRational.java
Exception in thread "main" java.lang.NoClassDefFoundError: TestRational/java
------------------

[This message has been edited by Dianne Calhoun (edited September 30, 2001).]


Thanks, Dianne
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
They both compile, but when I run the TestRational.java, it gives
me the following error, ....

C:\myjava\assignment2\problem1>java TestRational.java
Exception in thread "main" java.lang.NoClassDefFoundError:
TestRational/java


Rather than

C:\myjava\assignment2\problem1>java TestRational.java

try

C:\myjava\assignment2\problem1>java TestRational

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
Thanks, I knew that I just had a momentary lapse of memory. Comes from being frustrated working on these programs all weekend. Sometimes it just takes someone else looking.
------------------
Thanks, Dianne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with error in running program