Results 1 to 3 of 3
  1. #1
    hersman is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default <No main classes found> Error

    I am trying to run a Java application for my object-oriented class and I am running into a <No main classes found> error. It builds and compiles fine, but will not run.

    The following are my files if anyone can help me figure out what I am doing wrong:

    The package is named JavaPizza.
    The first file is named PizzaMain.java and is as follows:

    // Java Pizza Driver File
    // CS 252-V1
    // 04/22/11
    // Michael Hersman

    package JavaPizza;

    import javax.swing.JOptionPane;

    public class PizzaMain
    {
    public static void Main(String[]args)
    {
    char response = 'Y';

    while (response == 'Y')
    {
    Pizza pizza1 = new Pizza();
    pizza1.obtainUserInput();
    pizza1.displayCost();

    Pizza pizza2 = new Pizza();
    pizza2.obtainUserInput();
    pizza2.displayCost();

    if (pizza1.calcPriceSqIn() == pizza2.calcPriceSqIn())
    {
    pizza1.displayBestDeal("both");
    }
    else
    {
    if (pizza1.calcPriceSqIn() < pizza2.calcPriceSqIn())
    {
    pizza1.displayBestDeal("first");
    }
    else
    {
    pizza2.displayBestDeal("second");
    }
    }

    response = JOptionPane.showInputDialog(null, "Do you want to compare more pizzas?", "Comparison", JOptionPane.QUESTION_MESSAGE).charAt(0);
    response = Character.toUpperCase(response);
    }
    }
    }

    The second file is named Pizza.java and is as follows:

    // Java Pizza Header File
    // CS 252-V1
    // 04/22/11
    // Michael Hersman

    package JavaPizza;

    import javax.swing.JOptionPane;
    import java.text.*;

    public class Pizza
    {
    private String sizeString;
    private int size;
    private String shape;
    private String priceString;
    private double price;
    NumberFormat formatter = NumberFormat.getCurrencyInstance();

    // Constructors
    public Pizza()
    {
    }

    public Pizza(int sz, String sh, double pr)
    {
    size = sz;
    shape = sh;
    price = pr;
    }

    // Accessors
    public int getSize()
    {
    return size;
    }

    public String getShape()
    {
    return shape;
    }

    public double getPrice()
    {
    return price;
    }

    // Mutators
    public void setSize(int sz)
    {
    size = sz;
    }

    public void setShape(String sh)
    {
    shape = sh;
    }

    public void setPrice(double pr)
    {
    price = pr;
    }

    // Facilitators
    public double calcSqInches()
    {
    double sqInches;
    double radius = size / 2;
    final double pi = 3.142;

    if (shape.equals("square"))
    {
    sqInches = size * size;
    }
    else
    {
    sqInches = pi * radius * radius;
    }
    return sqInches;
    }

    public double calcPriceSqIn()
    {
    double priceSqIn;
    priceSqIn = price / calcSqInches();
    return priceSqIn;
    }

    public void displayCost()
    {
    System.out.println("This pizza is " + calcSqInches() + " square inches.");
    System.out.println("The cost per square inch of this " + shape + " pizza is " + formatter.format(calcPriceSqIn()));
    }

    public void displayBestDeal(String number)
    {
    if (number.equals("both"))
    {
    System.out.println("The cost of both pizzas are the same");
    System.out.println("Both pizzas cost " + formatter.format(calcPriceSqIn()) + " per square inch");
    }
    else
    {
    System.out.println("The " + number + " (" + shape + ", " + size + "-inch) pizza is the best deal.");
    }
    }

    public void obtainUserInput()
    {
    sizeString = JOptionPane.showInputDialog(null, "Enter the size of a pizza to be compared (in inches): ", "Size", JOptionPane.QUESTION_MESSAGE);
    size = Integer.parseInt(sizeString);

    priceString = JOptionPane.showInputDialog(null, "Enter the price of a pizza to be compared: ", "Price", JOptionPane.QUESTION_MESSAGE);
    price = Double.parseDouble(priceString);

    shape = JOptionPane.showInputDialog(null, "Enter the shape of a pizza to be compared (round or square): ", "Shape", JOptionPane.QUESTION_MESSAGE).toLowerCase();

    while (!shape.equals("round") && !shape.equals("square"))
    {
    System.out.println("The shape must be round or square.");
    shape = JOptionPane.showInputDialog(null, "Enter the shape of a pizza to be compared (round or square): ", "Shape", JOptionPane.QUESTION_MESSAGE).toLowerCase();
    }
    }
    }

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    java is case sensitive...in other words
    Main != main

  3. #3
    hersman is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Thank you so much. I was racking my brain changing all kinds of things trying to get it to work. Stupid simple error.

    Thanks again.

Similar Threads

  1. main method not found in class
    By eLancaster in forum New To Java
    Replies: 5
    Last Post: 02-09-2011, 09:48 AM
  2. Main Class not found
    By Draugnar in forum New To Java
    Replies: 3
    Last Post: 01-09-2010, 04:12 AM
  3. main class not found
    By abhijit in forum Networking
    Replies: 3
    Last Post: 10-01-2009, 10:05 AM
  4. No main class found error
    By jhering1986 in forum New To Java
    Replies: 17
    Last Post: 03-28-2009, 03:34 AM
  5. Replies: 4
    Last Post: 01-01-2009, 04:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •