What am I receiving the error java.lang.NoClassDefFoundError?

43 views Asked by At

I am trying to figure out what I am doing wrong?

package com.berrycalc;

import java.text.NumberFormat;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final byte MONTHS_IN_YEAR=12;
        final byte PERCENT=100;

        Scanner scanner=new Scanner(System.in);

        System.out.println("Welcome to Berry Bank! How much money will you need to borrow for your home loan?");
        int principal=scanner.nextInt();

        System.out.println("What is your expected Annual Interest Rate?");
        float annualInterest=scanner.nextFloat();
        float monthlyInterest=annualInterest/PERCENT/MONTHS_IN_YEAR;

        System.out.println("How many years are you expecting to pay on this loan? 30year/15year?");
        byte years= scanner.nextByte();
        int numberOfPayments=years*MONTHS_IN_YEAR;

        double mortgage=principal* (monthlyInterest*Math.pow(1+monthlyInterest,numberOfPayments)
                /(Math.pow(1+monthlyInterest, numberOfPayments)-1));

        String mortgageFormatted=NumberFormat.getCurrencyInstance().format(mortgage);
        System.out.println("Here is your Mortgage Payment ="+mortgageFormatted);
    }
}

Below is the error I am receiving when I try to run the Java program:

 sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name '*.java')
 java -classpath .:target/dependency/* Main
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/berrycalc/Main (wrong name: Main)
exit status 1
 ^C
 

Here is my replit link: https://replit.com/join/afsyvxnqas-amandaberry-tec

I copied my code from Visual Studio Code to here but now everything has broken.

0

There are 0 answers