views:

113

answers:

5

What does this error message usually mean for a java program?


Usage: java [-options] class [args...]
         (to execute a class)
 or  java [-options] -jar jarfile [args...]
       (to execute a jar file)

where options include:
-client       to select the "client" VM
-server       to select the "server" VM
-hotspot      is a synonym for the "client" VM  [deprecated]
              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 | -jre-no-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
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions
-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
Press any key to continue . . .

this is my code:

import java.io.*;
import java.util.*;

public class project2 {

 public static void main (String[] args) throws java.io.IOException {

 PCB[] Process_Table = new PCB[100];
 Queue Ready_Q = new Queue();
 Queue Terminated_Q = new Queue();
 PCB CPU = null;  //this is a pointer
 int global_time = 0;
 int CPU_time;

    //inputStream = new BufferedReader(new FileReader();


  do
 {
  //Scan the input file for processes with arrival_time equal to global_time
     try {
BufferedReader in = new BufferedReader(new FileReader("processes2.txt"));

        int c;
        boolean found = false;
        while ((c = in.read()) == global_time) {
             found = true;
             }


             String line = in.readLine();
             String[] nProcess = (line.split("\\|"));


                             boolean isThereNull = false;

                                for (int i=0;i<Process_Table.length;i++){
                                   if (Process_Table[i]==null){
                                       isThereNull = true;
                                    }//end if
                                }//end for

        if (found == true && isThereNull == true){

            PCB processX = new PCB(nProcess); //create new pcb
            processX.setStatus('r');

            //insert the pcb into the process table
            for(int i=0; i<101; i++){
                while(Process_Table[i]==null){
                    processX.setPID(i);
                    Process_Table[i]=processX;
                    }
                }//end for


            //add process to the ready q
            Ready_Q.put(processX);

                    //check if it worked
                    //System.out.println(Ready_Q.getAll());
                              }//end if
        else{
            System.out.println("Process Creation Delayed");
            }


        }catch (IOException e) {
            System.out.println("I/O exception: " + e);
            }







  }//end do
  while(Ready_Q.isEmpty()==false && CPU != null);/*Ready_Q and CPU are not empty*/

}//end main }//end class

A: 

Did you try to run "java" without any command line parameters?

Bryce Fischer
i didnt type java. i pressed control + 2 to execute
Luron
well, not sure what program you are pressing "control + 2" in, but if it executes a command, then it isn't passing anything to "java". If the arguments were incorrect, then you'd get an entirely different error message.
Bryce Fischer
java textpad. i said it above
Luron
Try this site: http://leepoint.net/notes-java/tools/50textpad.html . Highlights: 1) ensure you save your file with the same name as your class, with a .java extension. Example: public class TestClass ==> TestClass.java. 2) Tools -> External Tools -> Compile Java. 3) Tools -> External Tools -> Run Java Application
Bryce Fischer
1. yeh i did that. i even checked all the other programs to make sure i did that. 2. when i compile it comes up with this: Note: U:\Senior Year\CS451- Operating Systems\Project2 cpu scheduling\project2.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.
Luron
oooh. well now its doing this: Process Creation DelayedException in thread "main" java.util.NoSuchElementException at java.util.LinkedList.remove(LinkedList.java:788) at java.util.LinkedList.removeFirst(LinkedList.java:134) at Queue.Schedule(Queue.java:48) at project2.main(project2.java:72)Press any key to continue . . .
Luron
A: 

It could mean anything. You've screwed up the arguments.

Chris Dennett
+1  A: 

It means that you have not called the java program correctly. On the very first line, it shows you how to use java and the remaining parts are the parameters you can pass to JVM.

What are you trying to execute and how are you executing it?

mezzie
A: 

Its not an error message, it means you typed 'java' at the command prompt without any options or java -help, command 'java' is used to run a java program.

johnbk
i didnt type java. i pressed control + 2 to execute
Luron
A: 

Since you've indicated you're trying to run this from within textpad, maybe the advice here will be helpful. I suspect maybe the section with this title might be related to your problem although it's not exactly the issue you're having.

Q: This message comes out when I try to run my program in TextPad. What's wrong?

Exception in thread "main" java.lang.NoClassDefFoundError

Dave Costa