View Single Post
  #7 (permalink)  
Old March 20th, 2013, 10:41 AM
Alonsodev Alonsodev is offline
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compiles, but errors out when trying to run it

My code compiles when I enter javac TestTax.java on the command line,
but when I try to run it it gives me the following error:
//--------------------------------------------------------------------

C:\Users\uriel.gutierrez\workspace\Lesson5\src\les son5>java TestTax 100 AR 2
Exception in thread "main" java.lang.NoClassDefFoundError: TestTax (wrong name:
lesson5/TestTax)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unkno wn Source)

C:\Users\uriel.gutierrez\workspace\Lesson5\src\les son5>
//------------------------------------------------------------------------------------

package lesson5;



public class TestTax {
public static void main(String[] args) {
if (args.length !=3){
System.out.println("Sample usage of the program: " + " java TestTax 5000 NJ 2");
System.exit(0);
}

double grossIncome = Double.parseDouble(args[0]);
String state = args[1];
int dependents = Integer.parseInt(args[2]);
class Tax {
double gi;
String st;
int depen;


public double calcTax(double gi, String st, int depen){
this.gi = gi;
this.st = st;
this.depen = depen;

double stateTax=0;
if (gi < 30000){
stateTax=gi*0.05;
}
else {
stateTax= gi*0.07;
}
return stateTax;
}


}

Tax t = new Tax();


double yourTax = t.calcTax(grossIncome, state, dependents);

System.out.println("Your tax is " + yourTax);

}

}


Any suggestions?
Reply With Quote