• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Help with error in running program

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Dianne Calhoun
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic