Duron Weathington
Duron Weathington

Reputation: 9

Program is not compiling for Java what am I Missing

package freshjuice;


class FreshJuice {

    enum FreshJuiceSize { SMALL, MEDIUM, LARGE }
        FreshJuiceSize size;
    }


}

public class FreshJuiceTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        FreshJuice juice = new FreshJuice();
        juice.size = FreshJuice.FreshJuiceSize.MEDIUM ;
        System.out.println("Size: " + juice.size);
        // TODO code application logic here
    }

}

This is the error message I am getting:

Error: Main method not found in class freshjuice.FreshJuice, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
C:\Users\TheGODMasterDu\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 2 seconds)

Upvotes: 0

Views: 117

Answers (2)

Digvijaysinh Gohil
Digvijaysinh Gohil

Reputation: 1455

Your file name is FreshJuice.java which does not contains main()
In short netbeans looking for main() in your first class

Either change your file name to FreshJuiceTest.java or swap the code of your classes and define FreshJuice.java as public and remove public from second class

Upvotes: 0

user3237736
user3237736

Reputation: 857

Your file must be called FreshJuiceTest.java, because that is the class where your main method is located.

Upvotes: 2

Related Questions