-1

Possible Duplicate:
Exception in thread “main” java.lang.UnsupportedClassVersionError: a (Unsupporte d major.minor version 51.0)

I am currently working on a class that is part of a lab assignment. I wrote the class and my professor provided the main class. When I run the main.class that she provided in Net Beans I receive the following errors:

java.lang.UnsupportedClassVersionError: csit1520/lab1f/Main : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) 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:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: csit1520.lab1f.Main. Program will exit. Exception in thread "main" Java Result:1 ____________________________________

I am also attaching my CreditCard.class and the main.class. Any help is greatly appreciated. I am new to programming and have no idea what I am doing wrong.


THE MAIN CLASS
package csit.lab1f;
import java.util.Scanner;

 /**
 *
 */
 public class Main {
 public static void main(String a[] )
{
    Scanner input = new Scanner( System.in );
    double balance; // user entered

    // get first balance from user
    System.out.println( "Enter account balance(0 to end): ");
    balance = input.nextDouble();
    while ( balance != 0 )
   {
        // get a credit card with user entered balance
        CreditCard c = new CreditCard( balance );
        // calculate card's new interest, balance, min payment
        c.calculateStatement();
        // print card's statement
        c.printStatement();
        // get next balance
        System.out.println( "Enter account balance (0 to end): ");
        balance = input.nextDouble();
    }
}
} 

MY CREDIT CARD CLASS

package csit.lab1f;

/**
 *
 * 
 */
public class CreditCard {

  public final static double MINIMUM_PAYMENT_PERCENT = 0.1;
  public final static double HIGH_INTEREST_BORDER = 1000;
  public final static double HIGH_INTEREST = 0.015;
  public final static double LOW_INTEREST = 0.01;
  public final static double MINIMUM_PAYMENT = 10.0;    
  int nextAccountNumber = 12340000;

  private int accountID;
  private double previousBalance;
  private double interest;
  private double currentBalance = interest + previousBalance;
  private double minimumPayment;



  public CreditCard(){
  accountID = nextAccountNumber;
  nextAccountNumber++;
  previousBalance = 0;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}

  public CreditCard(double b){
  previousBalance = b;
  accountID = nextAccountNumber;
  nextAccountNumber++;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}

  public CreditCard(int a, double b){
  previousBalance = b;
  accountID = a;
  nextAccountNumber ++;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}      

  public void setInterest(double i){
  interest = i;}

  public double getInterest(){
  return interest;}

  public void setnextAccountNumber(int a){
  nextAccountNumber = a;}

  public int getnextAccountNumber(){
  return nextAccountNumber;}

  public void setaccountId(int acct){
  accountID = acct; }

  public int getaccountId(){
  return accountID;}

  public void setpreviousBalance(double p){
  previousBalance = p;}

  public double getpreviousBalance(){
  return previousBalance;}

  public void setminimumPayment(double pm){
  minimumPayment = pm;}

  public double getminimumPayment(){
  return minimumPayment;}

  public void setcurrentBalance(double cb){
  currentBalance = cb; }

  public double getcurrentBalance (){
  return currentBalance; }



  public void calculateStatement(){
  if (previousBalance <= 1000){
        interest = previousBalance* 0.015;}

  else { 
       interest = 15+(previousBalance - 1000)*0.01;}

  currentBalance = previousBalance + interest;

  if (currentBalance < 10){
        minimumPayment = currentBalance;}

  else  {minimumPayment = currentBalance * .10; }

  }

  public void printStatement(){

  String string1 = String.format ("Your old account balance  S%4.2f",previousBalance);      
  String string2 = String.format ("Your current interest $%3.2f",interest);
  String string3 = String.format ("Your new account balance $%3.2f",currentBalance);                  
  String string4 = String.format ("Your minimum payment $%4.2f",minimumPayment);                 


  System.out.println(string1);

  System.out.println(string2);

  System.out.println(string3);

  System.out.println(string4);
  }




 }
Community
  • 1
  • 1
user1658732
  • 1
  • 1
  • 1

1 Answers1

4

If you look at the first sentence in the error, you can see you're running a Unsupported Class Version. Just update java and you should be good to go!

Kjeld Perquin
  • 121
  • 2
  • 9
  • Thanks. This was an odd issue. My net beans project was corrupt. I took my code and pasted it into a new project. The new project is working and no errors. – user1658732 Sep 10 '12 at 00:29