Java – “Error: Could not find or load main class” Error
<p><img src="http://puu.sh/1ITnS.png" alt="the error and the class"></p>

<p>When I name the class file Main.class, java says it has the wrong name, and when I name it shop.Main.class it says that the main class can't be found. Can anyone help?</p>

<pre><code>package shop;

import java.text.DecimalFormat;

public class Main
{  
    public static void main(String args[])
    {  
        Cart cart = new Cart(new Catalogue());
        printOrder(cart);
    }

    public static void printOrder(Cart cart)
    {
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println("Your order:");
        for(int itemIndex = 0; itemIndex &lt; cart.itemsInCart.products.size(); 
            itemIndex++)
            if (cart.itemsInCart.products.get(itemIndex).quantity != 0)
                System.out.println(cart.itemsInCart.products.get(itemIndex).quantity 
                    + " " + cart.itemsInCart.products.get(itemIndex).name 
                    + " $"+ df.format(cart.itemsInCart.products.get(itemIndex).price) 
                    + " = $" + df.format
                    ((cart.itemsInCart.products.get(itemIndex).quantity 
                    * cart.itemsInCart.products.get(itemIndex).price)));

        double subtotal = 0;
        int taxPercent = 20;
        double tax;
        double total;

        for(int itemIndex = 0; itemIndex &lt; cart.itemsInCart.products.size(); 
            itemIndex++)
            subtotal += cart.itemsInCart.products.get(itemIndex).quantity 
            * cart.itemsInCart.products.get(itemIndex).price;
        tax = subtotal * taxPercent / 100;
        total = subtotal + tax;


        System.out.print("Subtotal: $" + df.format(subtotal) 
            + " Tax @ " + taxPercent + "%: $" + df.format(tax) 
            + " Grand Total: $" + df.format(total));
    }  
}
</code></pre>

<p>Ignore between the following two lines</p>

<p>–––––––––––––––––––––––––</p>

<p>Edit Summary</p>

<p>Oops! Your edit couldn't be submitted because:</p>

<p>Your post does not have much context to explain the code sections; please explain your scenario more clearly.</p>

<p>cancel</p>

<p>––––––––––––––––––––––---</p>
