Hi i need help with the code ive done in java, iv got a project im doing and i get this when i run my program.

--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]

   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -client   to select the "client" VM
    -server   to select the "server" VM
                  The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

Process completed.

Recommended Answers

All 9 Replies

heres my code

import javax.swing.JOptionPane;

import java.util.*;

import java.lang.*;





public class PrizeCollection{

static  String[] Name = new String [5];

static  String[] Description = new String [5];
static  String[] Color =new String[5];

static  float [] Price = new float [5];

  public static void main (String[]args)

    {





        int option = 0;

        while (option!=4)

        {



            option = Integer.parseInt(JOptionPane.showInputDialog( "Please choose an option: \n"

                +"1-Enter the detailes of the prize\n"

                    +"2 - Print the details of a prize\n"

                        +"3 - Search for a prize that has a certain value or by the description \n"

                            +"4 - Quit" ));



                            if (option ==1);

                                EnterDetails (Name,Description,Color,Price);

                            if (option==2)

                                printDetails(Name,Description,Color,Price);

                            if (option==3)

                                searchDetails(Name,Description,Color,Price);

      }



        System.exit(0);

    }

      static void EnterDetails(String Name[],String Description[],String Color[], float Price[])

    {

        for (int p=0; p<5; p++){

            Name[p] = JOptionPane.showInputDialog(null,"Please enter the name of the prize");

            Description[p] = JOptionPane.showInputDialog(null,"Please enter the description of the prize");

            Color[p] = JOptionPane.showInputDialog(null,"Please enter the color of the Prize");

            Price[p] = Float.parseFloat(JOptionPane.showInputDialog(null,"Please enter the price of the prize"));

            }

    }

            //method to search

            public static void searchDetails(String Name[], String Description[], String Color[], float Price[])



            {

                String search_a_Prize = JOptionPane.showInputDialog("Please enter the name of the prize you are searching for");

                boolean  _a_prize_is_found = false;

                    //loop start

                    for(int p=0; p<Name.length; p++)



                    {

                        if (Name[p].equals (search_a_Prize))

                        {

                            System.out.println("Successful search! A prize is found");

                            System.out.println("The prize is: "+ Name[p] + "\t\t Description: " + Description[p] + "\t\t Color: " + Color[p] + "\t\t Price: " + Price[p]);



                            _a_prize_is_found = true; //if this is the case the program will continue to the next instruction



                        }

                    } // loop ends



                    if (_a_prize_is_found ==false)

                        System.out.println("No prize found");

            }// search method ends



            //method to show the list of prizes



            public static void printDetails(String Name[],String Description[], String Color[], float[] price2)

            {

                for (int p=0; p<Name.length; p++)

                {

                    System.out.println (Name[p] + " " + Description[p] + " " + Color[p] + " " + price2[p]);

                    // prints list

                }
            }      



                // method to exit program

                public static void Exit()

                {

                    System.exit(0);// end program



                }




    }  

It seems there's an error in the syntax of the java command that you are trying to use to run your program. Exactly what are you typing?

This is what im doing:

Separate arrays to store individual details of each item
searching method 
useful comments, good indentation, good use of variable names


Display a menu of options (as below) to allow a user to manipulate three arrays which together represent prizes in a programming competition, until quit is selected.
o   Enter  details of a prize ( user is requested to enter the details of a prize from the keyboard)
o   Print the details stored for all prizes 
o   Search for a prize with a particular value OR by description
o   Quit
Three arrays to represent details relating to prizes. 
   Declaration and initialisation of variables.
   Separate arrays to store individual details of each prize.  A  prize requires storage of :
•   A description 
•   colour
•   value of prize 
   A menu of options dependent on an integer variable
The facility to display how many prize details are stored in the arrays.
The facility to request and accept input of a prize,  and store in the next empty array elements.
A facility to print the details of all prizes stored in the arrays.
A search method to allow searching for a prize (with a particular value OR by description).

Very interesting, but irrelevant to my question.
You are getting the java command wrong. What exactly did you type?

can you give me example of what you mean? ive only been doing java for a year so not 100% sure.

What exactly did you type at the command prompt when you were trying to run your java program? I don't know how to make that question any simpler.

What action did you perform to try to run the program?

You have code. You an error. How did you run the code to get to the error?

Be specific.

Im using jcreator i built the file then i ran it, i tried the same thing on eclipse and it worked fine?

Looks like something wrong with jcreator setup? The code isn't the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.