我目前正在开设一个实验室作业的课程。我写了课,我的教授提供了主要课程。当我运行她在Net Beans中提供的main.class时,我收到以下错误:
java.lang.UnsupportedClassVersionError:csit1520 / lab1f / Main:不支持的major.minor版本51.0 at java.lang.ClassLoader.defineClass1(Native Method) 在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) 在java.net.URLClassLoader $ 1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) 在java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 找不到主类:csit1520.lab1f.Main。程序将会退出。 线程“main”Java结果中的异常:1 ____________________________________
我还附加了我的CreditCard.class和main.class。任何帮助是极大的赞赏。我是编程新手,不知道我做错了什么。
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);
}
}
答案 0 :(得分:4)
如果查看错误中的第一句,您可以看到您正在运行不支持的类版本。 只是更新java,你应该好好去!