0

I am trying to make a paint dispenser simulation prototype console application with java. searched everywhere and can't seem to find out why this code won't work. I use netbeans. what I'm trying to do with this code is to display the menu, ask user for input, when user inputs a number it selects that option from menu and then I need to start getting those options to work once I have the menu working. Any help is appreciated thanks. My code so far is shown below.

    package paintdispensersimulation;

    import java.util.Scanner;
    /**
    *
    * @author Kris Newton (M2124910)
    */
    public class PaintDispenserSimulation   //
    {                                       //Open Public Class 
    public static void main(String[] args)  //
    {                                       //Start Main
        Scanner in = new Scanner (System.in);   //
        int option;                             //
        boolean quit = false;                   //Declare variables                                  
        do  //
        {   //Start Do
            System.out.println("Please Make a selection:");                     //
            System.out.println("[1] Process New Job(Decimal Values)");          //
            System.out.println("[2] Process New Job(RGB Hexadecimal Values)");  //
            System.out.println("[3] Calibrate Dispenser");                      //
            System.out.println("[4] Display Summary Of Jobs");                  //
            System.out.println("[0] Exit");                                     //Print Menu
            option = in.nextInt();  //Declare User Input
            switch (option)         //Declare Switch
            {                       //Start Switch            
                case 1:                                                                     //If Option = 1
                    System.out.println("You Chose To: Process New Job(Decimal Values)");    //Print            
                    break;                                                                  //Break
                case 2:                                                                             //If Option = 2
                    System.out.println("You Chose To: Process New Job(RGB Hexadecimal Values)");    //Print  
                    break;                                                                          //Break                                                                          
                case 3:                                                                     //If Option = 3
                    System.out.println("You Chose To: Calibrate Dispenser");                //Print 
                    break;                                                                  //Break
                case 4:                                                                             //If Option = 4
                    System.out.println("You Chose To: Display Summary Of Jobs");                    //Print
                    break;                                                                          //Break
                case 0:                                                                     //If Option = 0
                    quit = true;                                                            //Quit                                                            
                    break;                                                                  //Break
                default:                                                                            //If Option Invalid
                    System.out.println("Selection Invalid: Please enter a valid selection.");       //Print           
            }   //End Switch           
        }   //End Do 
        while (!quit);                              //While Quit = True
        System.out.println("You Chose To: Exit");   //Print
    }   //End Main    
}   //End Public Class

This is the message I get when trying to run.

run:
java.lang.VerifyError: Constructor must call super() or this() before return in method paintdispensersimulation.PaintDispenserSimulation.<init>()V at offset 0
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
    at java.lang.Class.getMethod0(Class.java:2685)
    at java.lang.Class.getMethod(Class.java:1620)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
pgSystemTester
  • 8,979
  • 2
  • 23
  • 49
  • 5
    'Won't work' isn't very useful. How doesn't it work? – Karl Barker Feb 01 '13 at 15:55
  • pls define "doesn't work" – user902383 Feb 01 '13 at 15:59
  • Are you sure, u executed this program, before you confirmed its not working>? – sr01853 Feb 01 '13 at 16:01
  • using netbeans, it isn't displaying anything wrong in the code, but when it goes to run I get a pop up box saying you are trying to run with compiled errors. I cant seem to find any errors. This is what I get when it runs: – Mr Newton Bomb Feb 01 '13 at 16:02
  • paste this in the question. – sr01853 Feb 01 '13 at 16:05
  • 1
    From the error you pasted. think this must be useful . http://stackoverflow.com/questions/6560988/method-must-call-super-error-in-netbeans – sr01853 Feb 01 '13 at 16:07
  • It must be due to NetBeans installation. I tried this both on Eclipse and NetBeans as well as compiling with javac from command line and it compiles and runs normally. What OS are you using? – mutantkeyboard Feb 01 '13 at 16:10
  • I'm using Windows 8 Pro 64bit, on a new computer, downloaded and installed the latest version, I could find of netbeans and java at the time a few weeks ago. – Mr Newton Bomb Feb 01 '13 at 16:14
  • hmm... this seems like an OS specific error. AFAIK you need to run java programs from desktop and they won't work under metro ...but since this is a console app did you try to running this with cmd in compatibility mode, because as of windows 7 there is difference in 64bit and 32bit console modes I think. – mutantkeyboard Feb 01 '13 at 16:21
  • I tried creating a new project with the same code with a different class name PDispenser, and started using this to see if it had any effect. this has a slight different effect. The clean and build works fine, but when you go to run main project it still shows errors. Alternatively instead of running main project clicked run file instead and it works perfectly fine, and yes the project was set to main. Guess I will just have to do it this way, but thanks for the help that you have all recommended. – Mr Newton Bomb Feb 01 '13 at 17:33

1 Answers1

0

I am able to run this code in eclipse.

VerifyError can mean the bytecode is invalid.

Basically, this is a compiler bug, or if class file is corrupted

Try compiling with a different JDK version and on a different machine.

DangerDan
  • 519
  • 2
  • 13