Good evening all I have some posted code here for a fraction program in java.

Problem is it works only in Eclipse but i am having a hard time to run in it in Command line.

Here are the 2 parts of the programs

one is called Fraction and second one is Tester

Here is the code for Fraction

Ok here is the code for TesterCode:package fractions; public class Fraction { // Constructor: sets numerator and denominator public Fraction(int num, int denom) { this.numerator=num; this.denominator=denom; } // Methods /////// // Returns object plus frac1 public Fraction add(Fraction frac1) { int num=this.getNum(); int denom=this.getDenom(); // Check that we have the same denominator for both fractions if (frac1.getDenom()!=denom) { int _denom=denom; num*=frac1.getDenom(); denom*=frac1.getDenom(); frac1=frac1.mult(new Fraction(_denom,_denom)); } num+=frac1.getNum(); return new Fraction(num,denom); } // Returns object minus frac1 public Fraction minus(Fraction frac1) { int num=this.getNum(); int denom=this.getDenom(); // Check that we have the same denominator for both fractions if (frac1.getDenom()!=denom) { int _denom=denom; num*=frac1.getDenom(); denom*=frac1.getDenom(); frac1=frac1.mult(new Fraction(_denom,_denom)); } num-=frac1.getNum(); return new Fraction(num,denom); } // Returns object times frac1 public Fraction mult(Fraction frac1) { int num=this.getNum(); int denom=this.getDenom(); num*=frac1.getNum(); denom*=frac1.getDenom(); return new Fraction(num,denom); } // Returns object divided by frac1 public Fraction div(Fraction frac1) { int num=this.getNum(); int denom=this.getDenom(); num*=frac1.getDenom(); denom*=frac1.getNum(); return new Fraction(num,denom); } // Returns numerator of frac1 public int getNum() { return this.numerator; } // Returns denominator of frac1 public int getDenom() { return this.denominator; } // Data members private int numerator; private int denominator; }

So that is that. it somewhat works in Eclipse but not in command line. So i am confused as to what it does not work work there. These are the error messages I get in command line on itCode:package fractions; public class Tester { public static void main(String[] args) { Fraction frac1=new Fraction(1,3); Fraction frac2=new Fraction(2,5); Fraction fracAdd=frac2.add(frac1); Fraction fracMinus=frac2.minus(frac1); Fraction fracMult=frac2.mult(frac1); Fraction fracDiv=frac2.div(frac1); System.out.println(toString(frac2)+" + "+toString(frac1)+" = "+toString(fracAdd)); System.out.println(toString(frac2)+" - "+toString(frac1)+" = "+toString(fracMinus)); System.out.println(toString(frac2)+" * "+toString(frac1)+" = "+toString(fracMult)); System.out.println(toString(frac2)+" / "+toString(frac1)+" = "+toString(fracDiv)); } public static String toString(Fraction frac) { return frac.getNum()+"/"+frac.getDenom(); } }

For when i got Javac and java Fraction this message i get for it in command line

When i javac Tester this is what i get as messageCode:Exception in thread "main" java.lang.NoClassDefFoundError: Fraction (wrong name: fractions/Fraction) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

So thank you all for taking the time to go over this. It is whacking my mind that it works in one spot but not that other, feel free to run this yourself to see what i mean.Code:Tester.java:20: cannot find symbol symbol : class Fraction location: class fractions.Tester public static String toString(Fraction frac) { ^ Tester.java:6: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction frac1=new Fraction(1,3); ^ Tester.java:6: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction frac1=new Fraction(1,3); ^ Tester.java:7: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction frac2=new Fraction(2,5); ^ Tester.java:7: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction frac2=new Fraction(2,5); ^ Tester.java:9: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction fracAdd=frac2.add(frac1); ^ Tester.java:10: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction fracMinus=frac2.minus(frac1); ^ Tester.java:11: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction fracMult=frac2.mult(frac1); ^ Tester.java:12: cannot find symbol symbol : class Fraction location: class fractions.Tester Fraction fracDiv=frac2.div(frac1); ^ 9 errors

Thanks all. and thanks for all feedback.