Program refuses to compile

Hi i seem to be facing an error due to one line in my program. can somebody please help
import java.io.*;
class p13_guess
     //Global Variables
     static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );
     public static void main (String[] args) throws IOException
// variable section
     long guess = -1;
     RandomNumber secret = new RandomNumber() ;
     System.out.println("Welcome to the program that guesses a number between 1 and 100:\n");
     secret.generate();
     while ((guess!= 0) && (guess != secret.number))
          System.out.println("Please enter your guess\n");
          guess = validatedLongInput ();
          if (guess<secret.number)
          System.out.println("too small");
     else
          if (guess>secret.number)
          System.out.println("too big");
     else
          System.out.println("Congratulations");
public static long validatedLongInput() throws IOException
// variable declaration
boolean ok;
long result=0;
ok = false;
while (!ok)
ok = true;
try
result = Long.parseInt (stdin.readLine());
catch (NumberFormatException Error)
System.out.print("ERROR - type a number.");
ok = false;
return result;
P:S this program is made to generate and random number and the user has to guess it

When you post code, highlight it and click the CODE button to retain formatting.
Do you think it would be a good idea to post your error message(s) as well? We don't have crystal balls.

Similar Messages

  • Getting an error when running my program but it compiles.

    Hey guys, I'm having a problem running the program. Everything compiles correctly, but then I get the error code linked below. Everything I think is correct here. Any ideas? I posted CinReader as well in case you wanted to try compiling and running it yourself.
    Thanks
    public class TextShuffleLevel
         private String jumble;
         private String [] matchString;
         public TextShuffleLevel ()
              jumble = "dunops";
              matchString = new String[5];
              matchString[0] = new String("abound");
              matchString[1] = new String("bound");
              matchString[2] = new String("undo");
              matchString[3] = new String("band");
              matchString[4] = new String("bond");
         public TextShuffleLevel (int whichDefaultLevel)
              if (whichDefaultLevel == 1)
                   jumble = "dunops";
                   matchString = new String[5];
                   matchString[0] = new String("abound");
                   matchString[1] = new String("bound");
                   matchString[2] = new String("undo");
                   matchString[3] = new String("band");
                   matchString[4] = new String("bond");
              else if (whichDefaultLevel == 2)
                   jumble = "srcaso";
                   matchString = new String[11];
                   matchString[0] = new String("across");
                   matchString[1] = new String("crass");
                   matchString[2] = new String("cross");
                   matchString[3] = new String("scars");
                   matchString[4] = new String("soars");
                   matchString[5] = new String("arcs");
                   matchString[6] = new String("soar");
                   matchString[7] = new String("scar");
                   matchString[8] = new String("oars");
                   matchString[9] = new String("cars");
                   matchString[10] = new String("orcs");
              else
                   jumble = "eplcis";
                   matchString = new String[19];
                   matchString[0] = new String("splice");
                   matchString[1] = new String("spiel");
                   matchString[2] = new String("plies");
                   matchString[3] = new String("slice");
                   matchString[4] = new String("clips");
                   matchString[5] = new String("epics");
                   matchString[6] = new String("spice");
                   matchString[7] = new String("epic");
                   matchString[8] = new String("lice");
                   matchString[9] = new String("slip");
                   matchString[10] = new String("clip");
                   matchString[11] = new String("pile");
                   matchString[12] = new String("lisp");
                   matchString[13] = new String("pies");
                   matchString[14] = new String("isle");
                   matchString[15] = new String("lips");
                   matchString[16] = new String("lies");
                   matchString[17] = new String("ices");
                   matchString[18] = new String("pics");
         public TextShuffleLevel (String newJumble, String [] newMatchString)
              jumble = newJumble;
              matchString = newMatchString;
         /* This is the nasty one */
         public boolean findMatch (String matchTry)
              boolean foundMatch = false;
              for (int i=0; i<matchString.length; i++)
                   if (matchTry.equalsIgnoreCase(matchString))
                        foundMatch = true;
                        break;
              return foundMatch;
         public void setJumble (String newJumble)
              jumble = newJumble;
         public void setMatchStrings (String [] newMatchString)
              matchString = newMatchString;
         public String getJumble ()
              return jumble;
         public int getJumbleLength ()
              return jumble.length();
         public int getNumberOfMatches ()
              return matchString.length;
         public String[] getMatchString ()
              return matchString;
    public class TextShuffleGame
         private int playerLevel = 1; // start them on level 1
         private CinReader reader;
         private TextShuffleLevel l1;
         private TextShuffleLevel l2;
         private TextShuffleLevel l3;
         private TextShuffleLevel onTheFly;
         public TextShuffleGame ()
              reader = new CinReader();
              // Using Statically Set Levels
              l1 = new TextShuffleLevel(1);
              l2 = new TextShuffleLevel(2);
              l3 = new TextShuffleLevel(3);
              // this one allows for a 'custom' level
              String fly[] = {"tea","at", "ate"};
              onTheFly = new TextShuffleLevel("eta", fly);
         //Setup for levels
         public void go ()
              boolean quit = false;
              char choice = 'z';
              int lastLevel = 0;
              while (quit == false)
                   lastLevel = playerLevel;
                   if (playerLevel == 1)
                        play(l1);
                   else if (playerLevel == 2)
                        play(l2);
                   else if (playerLevel == 3)
                        play(l3);
                   else
                        play(onTheFly);
                   if (lastLevel == playerLevel)
                        System.out.print("Play the level again");
                   else
                        System.out.print("Play next level");
                   System.out.print("(y/n)? ");
                   choice = reader.readChar();
                   if (choice == 'N' || choice == 'n')
                        quit = true;
         //Playing each level the same
         public void play (TextShuffleLevel theLevel)
              int numGuesses = 0;
              int numCorrect = 0;
              String userString = "";
              System.out.println("What " + theLevel.getJumbleLength() + "-letter words can you get out of " +
                                                 theLevel.getJumble() + "?\n");
              while (numGuesses < 5 && numCorrect < theLevel.getNumberOfMatches())
                        System.out.print("Enter a string: ");
                        userString = reader.readString();
                        if (theLevel.findMatch(userString) == true)
                             System.out.println("Great! A match!");
                             numCorrect = numCorrect + 1;
                        else
                             System.out.println("Drat... not a match");
                             numGuesses = numGuesses + 1;
              if (numCorrect == theLevel.getNumberOfMatches())
                   System.out.println("Terrific! You are ready to try a harder jumble");
                   playerLevel = playerLevel + 1;
         /* FOR TESTING ONLY -- TO BE REMOVED FOR RELEASE */
         public static void main (String [] args)
              TextShuffleGame tsg = new TextShuffleGame();
              tsg.go();
    import java.io.*;
    import java.util.*;
    public class CinReader
         private static final int INT_MESSAGE = 0;
         private static final int DOUBLE_MESSAGE = 1;
         private static final int CHAR_MESSAGE = 2;
         private static final int STRING_MESSAGE = 3;
         private static final int BOOLEAN_MESSAGE = 4;
         private static final String DEFAULT_ERROR_MESSAGE = "Please reenter. ";
         private String prompt = "> ";
         private String [] errorMessages;
         public CinReader ()
              prompt = "> ";
              setDefaultMessages();
         public CinReader (String newPrompt)
              prompt = newPrompt;
              setDefaultMessages();
         public CinReader (String newPrompt, String [] newErrorMessages)
              prompt = newPrompt;
              if (newErrorMessages != null)
                   setErrorMessages(newErrorMessages);
              else
                   setDefaultMessages();
         public void setPrompt (String newPrompt)
              prompt = newPrompt;
         public void setErrorMessages (String [] newErrorMessages)
              if (newErrorMessages != null)
                   int diff = errorMessages.length - newErrorMessages.length;
                   // NEED A MINIMUM OF 5 ERROR MESSAGES TO AVOID ERRORS
                   if (diff > 0)
                        errorMessages = new String[5];
                        for (int i=0; i<5; i++)
                             if (i < newErrorMessages.length)
                                  errorMessages[i] = new String(newErrorMessages);
                             else
                                  errorMessages[i] = new String(DEFAULT_ERROR_MESSAGE);
                   else
                        errorMessages = newErrorMessages;
         public void setErrorMessage (int idx, String msg)
              if (idx >= 0 && idx < errorMessages.length)
                   errorMessages[idx] = msg;
         public void setErrorMessageString (String msg)
              errorMessages[STRING_MESSAGE] = msg;
         public void setErrorMessageInt (String msg)
              errorMessages[INT_MESSAGE] = msg;
         public void setErrorMessageDouble (String msg)
              errorMessages[DOUBLE_MESSAGE] = msg;
         public void setErrorMessageChar (String msg)
              errorMessages[CHAR_MESSAGE] = msg;
         public void setErrorMessageBoolean (String msg)
              errorMessages[BOOLEAN_MESSAGE] = msg;
         public String readString()
              char theChar = 'x';
              String result = "";
              boolean done = false;
              while (!done)
                   theChar = nextChar();
                   if (theChar == '\n')
                        done = true;
                   else if (theChar == '\r'){}
                   else
                        result = result + theChar;
              return result;
         public String readString (boolean allowEmpty)
              String result = readString();
              if (!allowEmpty)
                   while (result.length() == 0)
                        System.out.println("Empty input not allowed. " + errorMessages[STRING_MESSAGE]);
                        System.out.print(prompt);
                        result = readString();
              return result;
         public String readString (int charLimit)
              String result = readString();
              if (result.length() > charLimit)
                   result = result.substring(0, charLimit);
              return result;
         public String readString (boolean allowEmpty, int charLimit)
              String result = readString(allowEmpty);
              if (result.length() > charLimit)
                   result = result.substring(0, charLimit);
              return result;
         public int readInt()
              String inputString = "";
              int number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Integer.valueOf(inputString).intValue());
                        done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[INT_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public int readInt(int min, int max)
              String inputString = "";
              int number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Integer.valueOf(inputString).intValue());
                        if (number < min || number > max)
                             System.out.println("Please enter an integer between " + min + " and " + max);
                        else
                             done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[INT_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public double readDouble()
              String inputString = "";
              double number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Double.valueOf(inputString).doubleValue());
                        done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[DOUBLE_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public char readChar()
              boolean done = false;
              String inputString = "";
              char nonWhite = 'x';
              while (!done)
                   inputString = readString();
                   inputString = inputString.trim();
                   if (inputString.length() != 1)
                        System.out.println("Input must be a single character. " + errorMessages[CHAR_MESSAGE]);
                        System.out.print(prompt);
    else
    nonWhite = (inputString.charAt(0));
    done = true;
              return nonWhite;
         public char readChar (String range)
              char theChar = 'x';
              boolean done = false;
              while (!done)
                   theChar = readChar();
                   for (int i=0; i<range.length(); i++)
                        if (theChar == range.charAt(i))
                             done = true;
                             break;
                   if (!done)
                        System.out.print("Invalid input. Please enter one of the following -> ");
                        for (int i=0; i<range.length(); i++)
                             System.out.print(range.charAt(i) + " ");
                        System.out.print("\n" + prompt);
              return theChar;
         public boolean readBoolean()
              boolean done = false;
              String inputString = "";
              boolean result = false;
              while (!done)
                   inputString = readString(false);
                   inputString = inputString.trim();
                   if (inputString.equalsIgnoreCase("true") || inputString.equalsIgnoreCase("t"))
                        result = true;
                        done = true;
                   else if (inputString.equalsIgnoreCase("false") || inputString.equalsIgnoreCase("f"))
                        result = false;
                        done = true;
                   else
                        System.out.println("Input must be [t]rue or [f]alse. " + errorMessages[BOOLEAN_MESSAGE]);
                        System.out.print(prompt);
              return result;
         private void setDefaultMessages ()
              errorMessages = new String[5];
              for (int i=0; i<errorMessages.length; i++)
                   errorMessages[i] = new String(DEFAULT_ERROR_MESSAGE);
         private char nextChar()
              int charAsInt = -1;
              try
                   charAsInt = System.in.read();
              catch(IOException e)
                   System.out.println(e.getMessage());
                   System.out.println("Fatal error. Exiting program.");
                   System.exit(0);
              return (char)charAsInt;

    Ok, here's what I did using the JSE 8.1 IDE.
    1) I copied your code into a .java file named "TextShuffleGame".
    It generated about half a dozon errors.
    There are three classes in the program:
    TextShuffleLevel
    TextShuffleGame
    CinReader
    Each of these classes is declared "public" and I got the same error message on each one:
    "class ... is public, should be declared in a file name ... .java"
    so, I...
    2) tried changing them to "private".
    It then said: "modifier private not allowed here".
    so, I...
    3) deleted the modifiers for these three classes and left them as just class. No errors.
    The next two errors had to do with the two import statements:
    "import java.io.*;" and "import java.util.*;".
    It said: "'class' or 'identifier' expected" for both. So, I...
    4) moved them to the top of the source file.
    Didn't help at first. So, I...
    5) fiddle around with them a bit.
    I tried "java.io;" and "java.util;" and then "java.*;" by itself. Still got errors. So, I put them back as you had them and for some mysterious reason, my editor decided they were fine. oO
    This also corrected the last errors in the "CinReader" class. Here is the error-free code I now have in my "TextShuffleGame.java" file:
    import java.io.*;
    import java.util.*;
    class TextShuffleLevel
         private String jumble;
         private String [] matchString;
         public TextShuffleLevel ()
              jumble = "dunops";
              matchString = new String[5];
              matchString[0] = new String("abound");
              matchString[1] = new String("bound");
              matchString[2] = new String("undo");
              matchString[3] = new String("band");
              matchString[4] = new String("bond");
         public TextShuffleLevel (int whichDefaultLevel)
              if (whichDefaultLevel == 1)
                   jumble = "dunops";
                   matchString = new String[5];
                   matchString[0] = new String("abound");
                   matchString[1] = new String("bound");
                   matchString[2] = new String("undo");
                   matchString[3] = new String("band");
                   matchString[4] = new String("bond");
              else if (whichDefaultLevel == 2)
                   jumble = "srcaso";
                   matchString = new String[11];
                   matchString[0] = new String("across");
                   matchString[1] = new String("crass");
                   matchString[2] = new String("cross");
                   matchString[3] = new String("scars");
                   matchString[4] = new String("soars");
                   matchString[5] = new String("arcs");
                   matchString[6] = new String("soar");
                   matchString[7] = new String("scar");
                   matchString[8] = new String("oars");
                   matchString[9] = new String("cars");
                   matchString[10] = new String("orcs");
              else
                   jumble = "eplcis";
                   matchString = new String[19];
                   matchString[0] = new String("splice");
                   matchString[1] = new String("spiel");
                   matchString[2] = new String("plies");
                   matchString[3] = new String("slice");
                   matchString[4] = new String("clips");
                   matchString[5] = new String("epics");
                   matchString[6] = new String("spice");
                   matchString[7] = new String("epic");
                   matchString[8] = new String("lice");
                   matchString[9] = new String("slip");
                   matchString[10] = new String("clip");
                   matchString[11] = new String("pile");
                   matchString[12] = new String("lisp");
                   matchString[13] = new String("pies");
                   matchString[14] = new String("isle");
                   matchString[15] = new String("lips");
                   matchString[16] = new String("lies");
                   matchString[17] = new String("ices");
                   matchString[18] = new String("pics");
         public TextShuffleLevel (String newJumble, String [] newMatchString)
              jumble = newJumble;
              matchString = newMatchString;
         /* This is the nasty one */
         public boolean findMatch (String matchTry)
              boolean foundMatch = false;
              for (int i=0; i<matchString.length; i++)
                   if (matchTry.equalsIgnoreCase(matchString))
                        foundMatch = true;
                        break;
              return foundMatch;
         public void setJumble (String newJumble)
              jumble = newJumble;
         public void setMatchStrings (String [] newMatchString)
              matchString = newMatchString;
         public String getJumble ()
              return jumble;
         public int getJumbleLength ()
              return jumble.length();
         public int getNumberOfMatches ()
              return matchString.length;
         public String[] getMatchString ()
              return matchString;
    class TextShuffleGame
         private int playerLevel = 1; // start them on level 1
         private CinReader reader;
         private TextShuffleLevel l1;
         private TextShuffleLevel l2;
         private TextShuffleLevel l3;
         private TextShuffleLevel onTheFly;
         public TextShuffleGame ()
              reader = new CinReader();
              // Using Statically Set Levels
              l1 = new TextShuffleLevel(1);
              l2 = new TextShuffleLevel(2);
              l3 = new TextShuffleLevel(3);
              // this one allows for a 'custom' level
              String fly[] = {"tea","at", "ate"};
              onTheFly = new TextShuffleLevel("eta", fly);
         //Setup for levels
         public void go ()
              boolean quit = false;
              char choice = 'z';
              int lastLevel = 0;
              while (quit == false)
                   lastLevel = playerLevel;
                   if (playerLevel == 1)
                        play(l1);
                   else if (playerLevel == 2)
                        play(l2);
                   else if (playerLevel == 3)
                        play(l3);
                   else
                        play(onTheFly);
                   if (lastLevel == playerLevel)
                        System.out.print("Play the level again");
                   else
                        System.out.print("Play next level");
                   System.out.print("(y/n)? ");
                   choice = reader.readChar();
                   if (choice == 'N' || choice == 'n')
                        quit = true;
         //Playing each level the same
         public void play (TextShuffleLevel theLevel)
              int numGuesses = 0;
              int numCorrect = 0;
              String userString = "";
              System.out.println("What " + theLevel.getJumbleLength() + "-letter words can you get out of " +
                                                 theLevel.getJumble() + "?\n");
              while (numGuesses < 5 && numCorrect < theLevel.getNumberOfMatches())
                        System.out.print("Enter a string: ");
                        userString = reader.readString();
                        if (theLevel.findMatch(userString) == true)
                             System.out.println("Great! A match!");
                             numCorrect = numCorrect + 1;
                        else
                             System.out.println("Drat... not a match");
                             numGuesses = numGuesses + 1;
              if (numCorrect == theLevel.getNumberOfMatches())
                   System.out.println("Terrific! You are ready to try a harder jumble");
                   playerLevel = playerLevel + 1;
         /* FOR TESTING ONLY -- TO BE REMOVED FOR RELEASE */
         public static void main (String [] args)
              TextShuffleGame tsg = new TextShuffleGame();
              tsg.go();
    class CinReader
         private static final int INT_MESSAGE = 0;
         private static final int DOUBLE_MESSAGE = 1;
         private static final int CHAR_MESSAGE = 2;
         private static final int STRING_MESSAGE = 3;
         private static final int BOOLEAN_MESSAGE = 4;
         private static final String DEFAULT_ERROR_MESSAGE = "Please reenter. ";
         private String prompt = "> ";
         private String [] errorMessages;
         public CinReader ()
              prompt = "> ";
              setDefaultMessages();
         public CinReader (String newPrompt)
              prompt = newPrompt;
              setDefaultMessages();
         public CinReader (String newPrompt, String [] newErrorMessages)
              prompt = newPrompt;
              if (newErrorMessages != null)
                   setErrorMessages(newErrorMessages);
              else
                   setDefaultMessages();
         public void setPrompt (String newPrompt)
              prompt = newPrompt;
         public void setErrorMessages (String [] newErrorMessages)
              if (newErrorMessages != null)
                   int diff = errorMessages.length - newErrorMessages.length;
                   // NEED A MINIMUM OF 5 ERROR MESSAGES TO AVOID ERRORS
                   if (diff > 0)
                        errorMessages = new String[5];
                        for (int i=0; i<5; i++)
                             if (i < newErrorMessages.length)
                                  errorMessages[i] = new String(newErrorMessages[i]);
                             else
                                  errorMessages[i] = new String(DEFAULT_ERROR_MESSAGE);
                   else
                        errorMessages = newErrorMessages;
         public void setErrorMessage (int idx, String msg)
              if (idx >= 0 && idx < errorMessages.length)
                   errorMessages[idx] = msg;
         public void setErrorMessageString (String msg)
              errorMessages[STRING_MESSAGE] = msg;
         public void setErrorMessageInt (String msg)
              errorMessages[INT_MESSAGE] = msg;
         public void setErrorMessageDouble (String msg)
              errorMessages[DOUBLE_MESSAGE] = msg;
         public void setErrorMessageChar (String msg)
              errorMessages[CHAR_MESSAGE] = msg;
         public void setErrorMessageBoolean (String msg)
              errorMessages[BOOLEAN_MESSAGE] = msg;
         public String readString()
              char theChar = 'x';
              String result = "";
              boolean done = false;
              while (!done)
                   theChar = nextChar();
                   if (theChar == '\n')
                        done = true;
                   else if (theChar == '\r'){}
                   else
                        result = result + theChar;
              return result;
         public String readString (boolean allowEmpty)
              String result = readString();
              if (!allowEmpty)
                   while (result.length() == 0)
                        System.out.println("Empty input not allowed. " + errorMessages[STRING_MESSAGE]);
                        System.out.print(prompt);
                        result = readString();
              return result;
         public String readString (int charLimit)
              String result = readString();
              if (result.length() > charLimit)
                   result = result.substring(0, charLimit);
              return result;
         public String readString (boolean allowEmpty, int charLimit)
              String result = readString(allowEmpty);
              if (result.length() > charLimit)
                   result = result.substring(0, charLimit);
              return result;
         public int readInt()
              String inputString = "";
              int number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Integer.valueOf(inputString).intValue());
                        done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[INT_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public int readInt(int min, int max)
              String inputString = "";
              int number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Integer.valueOf(inputString).intValue());
                        if (number < min || number > max)
                             System.out.println("Please enter an integer between " + min + " and " + max);
                        else
                             done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[INT_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public double readDouble()
              String inputString = "";
              double number = 0;
              boolean done = false;
              while (!done)
                   try
                        inputString = readString();
                        inputString = inputString.trim();
                        number = (Double.valueOf(inputString).doubleValue());
                        done = true;
                   catch (NumberFormatException e)
                        System.out.println("Input is not an integer. " + errorMessages[DOUBLE_MESSAGE]);
                        System.out.print(prompt);
              return number;
         public char readChar()
              boolean done = false;
              String inputString = "";
              char nonWhite = 'x';
              while (!done)
                   inputString = readString();
                   inputString = inputString.trim();
                   if (inputString.length() != 1)
                        System.out.println("Input must be a single character. " + errorMessages[CHAR_MESSAGE]);
                        System.out.print(prompt);
    else
    nonWhite = (inputString.charAt(0));
    done = true;
              return nonWhite;
         public char readChar (String range)
              char theChar = 'x';
              boolean done = false;
              while (!done)
                   theChar = readChar();
                   for (int i=0; i<range.length(); i++)
                        if (theChar == range.charAt(i))
                             done = true;
                             break;
                   if (!done)
                        System.out.print("Invalid input. Please enter one of the following -> ");
                        for (int i=0; i<range.length(); i++)
                             System.out.print(range.charAt(i) + " ");
                        System.out.print("\n" + prompt);
              return theChar;
         public boolean readBoolean()
              boolean done = false;
              String inputString = "";
              boolean result = false;
              while (!done)
                   inputString = readString(false);
                   inputString = inputString.trim();
                   if (inputString.equalsIgnoreCase("true") || inputString.equalsIgnoreCase("t"))
                        result = true;
                        done = true;
                   else if (inputString.equalsIgnoreCase("false") || inputString.equalsIgnoreCase("f"))
                        result = false;
                        done = true;
                   else
                        System.out.println("Input must be [t]rue or [f]alse. " + errorMessages[BOOLEAN_MESSAGE]);
                        System.out.print(prompt);
              return result;
         private void setDefaultMessages ()
              errorMessages = new String[5];
              for (int i=0; i < errorMessages.length; i++)
                   errorMessages[i] = new String(DEFAULT_ERROR_MESSAGE);
         private char nextChar()
              int charAsInt = -1;
              try
                   charAsInt = System.in.read();
              catch(IOException e)
                   System.out.println(e.getMessage());
                   System.out.println("Fatal error. Exiting program.");
                   System.exit(0);
              return (char)charAsInt;
    Hope that helps.

  • Programming in C compiling with gcc

    Hi there,
    I've been working on this for a few days but can't seem to figure it out. I am taking an intro to programming class in which we are supposed to write command line C programs, to be compiled with gcc and tested on Linux's, specifically using Kate.
    I have installed Xcode and the Command Line Tools and have checked in xcode preferences and confirmed the install of command line tools worked. For some reason my "developer" folder is not where it should be, in usr.
    I know that v4 of Xcode works differently in this way but I am confused as to what this means for me and trying to write in C on my mac!
    Thanks everyone

    Xcode is a plain old OS X application now.
    There is no developer folder.

  • I have a new ipad 2.  The mail program  refuses to send forwarded emails because the recipient "doesn't accept relays."  My desktop and Blackberry forward emails to those recipients  without difficulty.  Help.

    I have a new ipad 2.  The mail program  refuses to send forwarded emails because the recipient "doesn't accept relays."  My desktop and Blackberry forward emails to those recipients  without difficulty.  Help.

    I suspect that you are using the Forwarding option within Workgroup Manager, and this works outside of the postfix alias scheme. I think you should just set those users you are forwarding to, to normal mail users, and put their forwarding rules ALSO in the alias file, so you would have:
    MAILER-DAEMON: postmaster
    postmaster: alex,yong
    alex: [email protected]
    That should do it. You really have to commit to either using Workgroup Manager or Postfix in their entirety. They don't really work too nicely in conjunction with each other.

  • Help!  I'm trying to re-install Final Cut after my MacBook crashed but every time I enter the serial number the program refuses to acknowledge it.  Anyone have a solution?

    Help!  I'm trying to re-install Final Cut after my MacBook crashed but every time I enter the serial number the program refuses to acknowledge it.  Anyone have a solution?

    Try here:
    https://discussions.apple.com/message/7565627#7565627
    Al

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • Adobe reader installed but programs refusing to acknowledge.

    Greetings,
    I have numerous educational programs which have resources in pdf format that since i have updated my version of adobe reader from 9 to X(latest update) refuse to open. All of these programs worked perfectly fine using adobe reader 9
    The messages i get from each program are all variations on "you do not have an application installed that can read documents with the pdf extension"
    All the programs have a graphical front end to them through which you navigate to the desired topic, click the link of the resource and it would normally open in reader since it should be picking up pdf files. They are part of the boardworks and heinemann product families if anyone reading this is into education.
    Im running windows 7 sp1 32bit and abobe reader x 10.1.0.. Have already tried a reinstall..
    Any help/suggestions would be appreciated.
    James

    I had a similar problem just now and what worked for me was i archived a email in MS outlook using the Adopbe PDF dropdown menu and then I had full access to X Pro again.
    Hope that this helps

  • Java gui program won't compile.

    The error I am getting in my compiler is missing return statement, then ill add some braces and get a class, interface, or enum expected error, and sometimes when i add some ill end up getting a reached the end without parcing error. Can someone look at this code and tell me what I need to do to make it compile, I am pretty sure it is just a brace thing, but I have run out of ideas:
    here is the code:
    public class Lab14 implements ActionListener
    // Application variables
    private JFrame myFrame;
    private JTextField txtInput;
    private JButton cmdRun;
    private JButton cmdExit;
    private JTextArea txaOutput;
    private static Random rand = new Random();
    private double trials;
    * Schedule a job for the event-dispatching thread
    * to create and show this application's GUI.
    * @param args program arguments
    public static void main(String[] args)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    Lab14 myLab14 = new Lab14();
    myLab14.createAndShowGUI();
    * Create and show the graphical user interface.
    private void createAndShowGUI()
    Container myPane;
    txtInput = new JTextField(10);
    cmdRun = new JButton("Run");
    cmdRun.addActionListener(this);
    cmdExit = new JButton("Quit");
    cmdExit.addActionListener(this);
    txaOutput = new JTextArea(35, 40);
    txaOutput.setEditable(false);
    // Set up and show the application frame
    myFrame = new JFrame("Lab14");
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myPane = myFrame.getContentPane();
    myPane.setLayout(new FlowLayout());
    myPane.add(new JLabel("Number of Trials"));
    myPane.add(txtInput);
    myPane.add(cmdRun);
    myPane.add(cmdExit);
    myPane.add(txaOutput);
    myFrame.pack();
    myFrame.setVisible(true);
    txtInput.requestFocus();
    * Enable user interaction.
    * @param ae the specified action event
    public void actionPerformed(ActionEvent ae)
    String number;
    String report;
    int dotSum = 0;
    int count = 0;
    int freq = 0;
    int prob = 0;
    Object source = ae.getSource();
    if (source.equals(cmdRun))
    try
    number = txtInput.getText();
    trials = Double.parseDouble(number);
    if (trials <= 0)
    throw new Exception(
    "The number of trials must be positive.");
    else
    while (count < trials)
    dotSum = dotSum + rand.nextInt(6) + 1;
    count++;
    txaOutput.setText(
    getReport(dotSum, freq, prob));
    catch (NumberFormatException nfe)
    txtInput.selectAll();
    txtInput.requestFocus();
    JOptionPane.showMessageDialog(
    myFrame,
    "The number of trials is not a number.",
    "Number Format Error",
    JOptionPane.ERROR_MESSAGE);
    catch (Exception e)
    txtInput.selectAll();
    txtInput.requestFocus();
    JOptionPane.showMessageDialog(
    myFrame,
    e.getMessage(),
    "Number Format Error",
    JOptionPane.ERROR_MESSAGE);
    else
    System.exit(0);
    * Get the report for the specified dot sum, frequency,
    * and probability. The output shows the results from
    * rolling the dice a selected number of trials.
    * @param dotSum the sum of the dots
    * @param frequency the frequency of the dice
    * @param probability the probability of rolling a specified amount
    * @return the report
    private String getReport(int dotSum,
    int freq,
    int prob)
    int count;
    int freq0;
    int freq1;
    int freq2;
    int freq3;
    int freq4;
    int freq5;
    int freq6;
    int freq7;
    int freq8;
    int freq9;
    int freq10;
    double prob0;
    double prob1;
    double prob2;
    double prob3;
    double prob4;
    double prob5;
    double prob6;
    double prob7;
    double prob8;
    double prob9;
    double prob10;
    String report;
    int numDice = 2;
    while (trials != 0)
    Dice myDice = new Dice(numDice);
    freq0 = 0;
    freq1 = 0;
    freq2 = 0;
    freq3 = 0;
    freq4 = 0;
    freq5 = 0;
    freq6 = 0;
    freq7 = 0;
    freq8 = 0;
    freq9 = 0;
    freq10 = 0;
    for (count = 0; count < trials; count++)
    switch (myDice.getDotSum())
    case 2: freq0++;
    break;
    case 3: freq1++;
    break;
    case 4: freq2++;
    break;
    case 5: freq3++;
    break;
    case 6: freq4++;
    break;
    case 7: freq5++;
    break;
    case 8: freq6++;
    break;
    case 9: freq7++;
    break;
    case 10: freq8++;
    break;
    case 11: freq9++;
    break;
    case 12: freq10++;
    prob0 = (double)freq0/(double)trials;
    prob1 = (double)freq1/(double)trials;
    prob2 = (double)freq2/(double)trials;
    prob3 = (double)freq3/(double)trials;
    prob4 = (double)freq4/(double)trials;
    prob5 = (double)freq5/(double)trials;
    prob6 = (double)freq6/(double)trials;
    prob7 = (double)freq7/(double)trials;
    prob8 = (double)freq8/(double)trials;
    prob9 = (double)freq9/(double)trials;
    prob10 = (double)freq10/(double)trials;
    double freqSum = freq0 + freq1 + freq2 + freq3 + freq4 +
    freq5 + freq6 + freq7 + freq8 + freq9 + freq10;
    double probSum = prob0 + prob1 + prob2 + prob3 + prob4 +
    prob5 + prob6 + prob7 + prob8 + prob9 + prob10;
    return
    String.format("%7s %9s %11s%n", "Dot Sum", "Frequency", "Probability")+
    String.format("%7s %9s %11s%n", "-------", "---------", "-----------")+
    String.format(" 2 %9d", freq0)+
    String.format(" %11.3f%n", prob0)+
    String.format(" 3 %9d", freq1)+
    String.format(" %11.3f%n", prob1)+
    String.format(" 4 %9d", freq2)+
    String.format(" %11.3f%n", prob2)+
    String.format(" 5 %9d", freq3)+
    String.format(" %11.3f%n", prob3)+
    String.format(" 6 %9d", freq4)+
    String.format(" %11.3f%n", prob4)+
    String.format(" 7 %9d", freq5)+
    String.format(" %11.3f%n", prob5)+
    String.format(" 8 %9d", freq6)+
    String.format(" %11.3f%n", prob6)+
    String.format(" 9 %9d", freq7)+
    String.format(" %11.3f%n", prob7)+
    String.format(" 10 %9d", freq8)+
    String.format(" %11.3f%n", prob8)+
    String.format(" 11 %9d", freq9)+
    String.format(" %11.3f%n", prob9)+
    String.format(" 12 %9d", freq10)+
    String.format(" %11.3f%n", prob10)+
    String.format("%7s %9s %11s%n", "-------", "---------", "-----------")+
    String.format("%18d", freqSum)+
    String.format("%13.3f%n", probSum);
    }

    border9 wrote:
    yes, but i wrote the bottom part of the code a while ago before I did know what an array list was, so I figured it would be easier just to paste that rather than make new code.Sounds to me like you're the type who just throws code at a wall hoping some of it will stick.
    You're not trying hard enough. Just posting your code here (and unformatted, to boot!) and saying "fix this for me" isn't going to cut it. This is not rent-a-coder.

  • This program is well compiled but does not work.

    I would like to know why this program does not work properly:
    the idea is :
    1. the user introduces a text as a string
    2.the progam creates a file (with a FileOutputStream)
    3. then this file is encripted according to DES (using JCE, cipheroutputStream)
    4.the new filw is an encripte file, whose content is introduced in a string (with a FileInputStream)
    (gives no probles of compilation!!)
    (don know why it does not work)
    here goes the code:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    import java.security.*;
    import javax.crypto.*;
    public class cuadro extends Applet{
         private TextArea area1 =new TextArea(5,50);
         private TextArea area2 =new TextArea(5,50);
         private Button encriptar=new Button("encriptar");
         private Button decriptar=new Button("decriptar");
         public cuadro(){
              layoutApplet();
              encriptar.addActionListener(new ButtonHandler());
              decriptar.addActionListener(new ButtonHandler());
              resize(400,400);
              private void layoutApplet(){
              Panel keyPanel = new Panel();
              keyPanel.add(encriptar);
              keyPanel.add(decriptar);
              Panel textPanel = new Panel();
              Panel texto1 = new Panel();
              Panel texto2 = new Panel();
              texto1.add(new Label("               plain text"));
              texto1.add(area1);
              texto2.add(new Label("               cipher text"));
              texto2.add(area2);
              textPanel.setLayout(new GridLayout(2,1));
              textPanel.add(texto1);
              textPanel.add(texto2);
              setLayout(new BorderLayout());
              add("North", keyPanel);
              add("Center", textPanel);
              public static String encriptar(String text1){
              //generar una clave
              SecretKey clave=null;
              String text2="";
              try{
              FileOutputStream fs =new FileOutputStream ("c:/javasoft/ti.txt");
              DataOutputStream es= new DataOutputStream(fs);
                   for(int i=0;i<text1.length();++i){
                        int j=text1.charAt(i);
                        es.write(j);
                   es.close();
              }catch(IOException e){
                   System.out.println("no funciona escritura");
              }catch(SecurityException e){
                   System.out.println("el fichero existe pero es un directorio");
              try{
                   //existe archivo DESkey.ser?
                   ObjectInputStream claveFich =new ObjectInputStream(new FileInputStream ("DESKey.ser"));
                   clave = (SecretKey) claveFich.readObject();
                   claveFich.close();
              }catch(FileNotFoundException e){
                   System.out.println("creando DESkey.ser");
                   //si no, generar generar y guardar clave nueva
              try{
                   KeyGenerator claveGen = KeyGenerator.getInstance("DES");
                   clave= claveGen.generateKey();
                   ObjectOutputStream claveFich = new ObjectOutputStream(new FileOutputStream("DESKey.ser"));
                   claveFich.writeObject(clave);
                   claveFich.close();
              }catch(NoSuchAlgorithmException ex){
                   System.out.println("DES key Generator no encontrado.");
                   System.exit(0);
              }catch(IOException ex){
                   System.out.println("error al salvar la clave");
                   System.exit(0);
         }catch(Exception e){
              System.out.println("error leyendo clave");
              System.exit(0);
         //crear una cifra
         Cipher cifra = null;
         try{
              cifra= Cipher.getInstance("DES/ECB/PKCS5Padding");
              cifra.init(Cipher.ENCRYPT_MODE,clave);
         }catch(InvalidKeyException e){
              System.out.println("clave no valida");
              System.exit(0);
         }catch(Exception e){
              System.out.println("error creando cifra");
              System.exit(0);
         //leer y encriptar el archivo
         try{
              DataInputStream in = new DataInputStream(new FileInputStream("c:/javasoft/ti.txt"));
              CipherOutputStream out = new CipherOutputStream(new DataOutputStream(new FileOutputStream("c:/javasoft/t.txt")),cifra);
              int i;
              do{
                   i=in.read();
                   if(i!=-1) out.write(i);
              }while (i!=-1);
              in.close();
              out.close();
         }catch(IOException e){
              System.out.println("error en lectura y encriptacion");
              System.exit(0);
         try{
              FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
              DataInputStream le =new DataInputStream(fe);
                   int i;
                   char c;
                   do{
                        i=le.read();
                        c= (char)i;
                        if(i!=-1){
                        text2 += text2.valueOf(c);
                   }while(i!=-1);
                        le.close();
              /*}catch(FileNotFoundException e){
                   System.out.println("fichero no encontrado");
                   System.exit(0);
              }catch(ClassNotFoundException e){
                   System.out.println("clase no encontrada");
                   System.exit(0);
              */}catch(IOException e){
                   System.out.println("error e/s");
                   System.exit(0);
              return text2;
         class ButtonHandler implements ActionListener{
         public void actionPerformed(ActionEvent e){
              try{
              if (e.getActionCommand().equals(encriptar.getLabel()))
                   //     area2.setText(t1)
                   area2.setText(encriptar(area1.getText()));
                   //area2.setText("escribe algo");
                   else if (e.getActionCommand().equals(decriptar.getLabel()))
                        System.out.println("esto es decriptar");
                        //area2.setText("hola");
         }catch(Exception ex){
              System.out.println("error en motor de encriptacion");
                   //else System.out.println("no coge el boton encriptado/decript");

    If you don't require your code to run as an applet, you will probably get more mileage from refactoring it to run as an application.
    As sudha_mp implied, an unsigned applet will fail on the line
    FileInputStream fe=new FileInputStream("c:/javasoft/t.txt");
    due to security restrictions. (Which, incidentally, are there for a very good reason)

  • Program with generics compiles without -source 1.5 but doesn't run.

    This could probably be considered a bug in J2SE1.5 beta 1.
    A program with generics that is compiled with JDK 1.5 beta1 without the "-source 1.5" option behaves oddly: it compiles but sometimes fails to execute. It shouldn't behave like that. It should fail in the compilation, with a complaint about using the wrong version of the language.
    This odd behaviour doesn't always occur! In the small program below, I get that behaviour when using the EnumSet.range method.
    If I only use the basic EnumSet, it does executes.
    -- Lars
    import java.util.EnumSet;
    import java.util.*;
    public class Example {
         public enum Season { WINTER, SPRING, SUMMER, FALL }
         public static EnumSet<Season> warmSeason = EnumSet.range(Season.SPRING, Season.FALL);
         public static void main(String[] args) {
              System.out.println("Season: ");     
              for (Season s : Season.values()) {
              System.out.println(s);
              System.out.println("Cold Season: ");     
              for (Season s : warmSeason) {
              System.out.println(s);

    Example.java:6: warning: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
        public enum Season { WINTER, SPRING, SUMMER, FALL }
               ^
    Example.java:6: ';' expected
        public enum Season { WINTER, SPRING, SUMMER, FALL }
                           ^
    Example.java:12: ';' expected
            for (Season s : Season.values()) {
                          ^
    Example.java:17: illegal start of expression
            for (Season s : warmSeason) {
            ^
    Example.java:20: ';' expected
        ^
    4 errors
    1 warning

  • [OCaml, lablgtk2, lablrsvg] My program doesn't compile (solved)

    Hi,
    I wrote few months ago (I used Ubuntu at that time, I just have installed ArchLinux one week ago) a little OCaml program which makes use of the lablgtk2 and lablrsvg libraries (OCaml bindings to gtk2 and rsvg).
    I installed ocaml and lablgtk2 (which normally contains lablrsvg, librsvg being flagged as a dependency), but when I try to compile, I get an error :
    $ ocamlc -w ys -I +lablgtk2 lablgtk.cma gtkInit.cmo lablrsvg.cma unix.cma entrelacs.cmo io.cmo entrelacs_IHM.ml -o Entrelacs
    File "entrelacs_IHM.ml", line 1, characters 0-1:
    Error: The file /usr/lib/ocaml/lablgtk2/lablrsvg.cma is not a bytecode object file
    make: *** [Entrelacs] Erreur 2
    The others files entrelacs.cmo and io.cmo doesn't need lablgtk2 (nor lablrsvg), and they compiled fine.
    In /usr/lib/ocaml/lablgtk2/, the file lablrsvg.cma exists, and `file' tells me that this is an "Objective caml library file (.cma) (Version 007)"
    The same program compiled fine when I used Ubuntu.
    What's wrong?
    Thank you
    (solved after the update of lablgtk2 today)
    Fractal
    Last edited by Fractal (2009-09-10 08:22:31)

    Things tend to move fasterYep... until something goes wrong... then you're completely stuffed, because you have no idea what's actually happening, because the idjit IDE is hiding all the gory details... it doesn't even tell you what it's doing, let alone how it's doing it, or what to do when it fails.
    Another argument for the command line is that it's simple. There are 16 distinct dialogues involved in adding a new jar to a library in jBuilder... There may well be less than 16 characters in the equivalent edition to the equivalent build command line. That's an extreme case, I admit, but it goes to disprove the notion that IDE's are simpler for noobs.
    Also, it's easier to get help on command line usage... because it's all text based you can just copy & paste the problematic command and it's output, and the eggspurts (tm) can do likewise with a response... and there are limited number of command lines out there... and *nix, windows, and mac cover maybe 99.5% of java users... and the eggspurts are likely to know all three (colectively if not as individuals) fairly well, because they deal with them all day every day.
    My belief is that noob's are better off at the command line until such time as they need (not just want to play with) a visual debugger... at which time its time to download netbeans and eclipse, and see which one suits you better... if you have money to splurge I'd also evaluate intelliJ... But avoid jBuilder, 2008 is total carp! The FREE eclipse is (IMHO) "nicer to use", and it has a LOT less bugs.
    Cheers. Keith.

  • Known-working program will not compile!

    Hey people. Rookie here!
    I'm trying to compile something I downloaded - I know the file works, and I have the latest SDK, but it won't compile! Its working with Graphics2D objects, and it seems to have a problem with some of the methods. This is what I get when I try to compile with javac.exe
    Unexpected Signal : EXCEPTION_FLT_STACK_CHECK (0xc0000092) occurred at PC=0xC1D212
    Function=[Unknown.]
    Library=(N/A)
    NOTE: We are unable to locate the function name symbol for the error
    just occurred. Please refer to release documentation for possible
    reason and solutions.
    Current Java thread:
    Dynamic libraries:
    0x00400000 - 0x0040C000      d:\java\bin\javac.exe
    0x77F50000 - 0x77FF7000      C:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F46000      C:\WINDOWS\system32\kernel32.dll
    0x77DD0000 - 0x77E5D000      C:\WINDOWS\system32\ADVAPI32.dll
    0x78000000 - 0x78087000      C:\WINDOWS\system32\RPCRT4.dll
    0x77C10000 - 0x77C63000      C:\WINDOWS\system32\MSVCRT.dll
    0x00280000 - 0x002F4000      C:\DOCUME~1\Chris\LOCALS~1\Temp\oxb59.tmp
    0x77340000 - 0x773CB000      C:\WINDOWS\system32\COMCTL32.DLL
    0x7E090000 - 0x7E0D1000      C:\WINDOWS\system32\GDI32.dll
    0x77D40000 - 0x77DCC000      C:\WINDOWS\system32\USER32.dll
    0x71B20000 - 0x71B31000      C:\WINDOWS\system32\MPR.DLL
    0x771B0000 - 0x772D4000      C:\WINDOWS\system32\OLE32.DLL
    0x77120000 - 0x771AB000      C:\WINDOWS\system32\OLEAUT32.DLL
    0x71AD0000 - 0x71AD8000      C:\WINDOWS\System32\WSOCK32.DLL
    0x71AB0000 - 0x71AC5000      C:\WINDOWS\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      C:\WINDOWS\System32\WS2HELP.dll
    0x08000000 - 0x08139000      d:\java\jre\bin\client\jvm.dll
    0x76B40000 - 0x76B6C000      C:\WINDOWS\System32\WINMM.dll
    0x10000000 - 0x10007000      d:\java\jre\bin\hpi.dll
    0x009B0000 - 0x009BE000      d:\java\jre\bin\verify.dll
    0x009C0000 - 0x009D9000      d:\java\jre\bin\java.dll
    0x009E0000 - 0x009ED000      d:\java\jre\bin\zip.dll
    0x76C90000 - 0x76CB2000      C:\WINDOWS\system32\imagehlp.dll
    0x6D510000 - 0x6D58D000      C:\WINDOWS\system32\DBGHELP.dll
    0x77C00000 - 0x77C07000      C:\WINDOWS\system32\VERSION.dll
    0x76BF0000 - 0x76BFB000      C:\WINDOWS\System32\PSAPI.DLL
    Heap at VM Abort:
    Heap
    def new generation total 576K, used 431K [0x10010000, 0x100b0000, 0x104f0000)
    eden
    This is driving me insane now, I would appreciate any help.
    Chris

    I see that you have installed in non-standard directories. If you didn't do this correctly, it is possibly causing the error.
    After checking per jsalonen's reply, double check that stuff is where you want it, and that your PATH (and if used, CLASSPATH) environment variables are correctly set. See Sun's Java Installation Instructions for PATH info.
    Change to the directory that has correct copies of javac.exe and java.exe, and try compiling. (These files are in the JAVA_HOME\bin directory, in my machine at C:\j2sdk1.4.2_05\bin). If that works, check that the copies of java.exe and javaw.exe in WINDOWS\System32 are the correct versions. Also check that the Registry keys under HKEY_LOCAL_MACHINE\Software\JavaSoft\ are pointing at the correct locations for each program.
    (You might want to uninstall and then reinstall using the default locations if nothing else works.)

  • Programs will not compile that have seperate classes

    I am trying to compile a program which has a seperate class, but it wont compile, it cant find the other class. I am compiling in the correct order, and I have tried re-compiling programs with seperate classes that I have done before, and they now wont compile. I tried compiling my program on my friends computer and it compiled fine.
    I am using jdk5.0 update 6 on Windows XP Pro
    Any help will be much appreciated

    That still doesnt work, it comes up with an extra
    error message now:
    "error reading PhoneEntry.java; error in opening zip
    file"Zip file?
    It sounds like you have some bogus zip file in your classpath.
    Did you try the exact command I posted?
    my two classes are PhoneEntry.java and
    PhoneBook.java
    PhoneEntry needs to be compiled before PhoneBookThat doesn't matter. Javac will take care of that automatically.
    PhoneEntry compiles fine, just when it tries to find
    PhoneBook it appears it cannot find the created
    PhoneEntry.class fileAll I can guess at is that you're doing this: javac -classpath .;something.zip *.java and something.zip either doesn't exist or is corrupt.

  • Newer version of the program of native compilation NCOMP

    Hi,
    I tried to use the ncomp program to make native compilation of a jar file in an Oracle 8.1.7 Database on Unix platform with jdk 1.2.2.
    It returns an error :
    Set the JAVA_HOME to the location of the jdk 1.1.x.
    It seems the version of ncomp I have is unable to work with our jdk 1.2.2
    Where could I find a newer version of ncomp which work with jdk 1.1.2 ?
    Thanks in advance
    Bye
    [email protected]
    null

    see your duplicate posting on metalink.

  • A simple Java program to be compiled with ojc and executed with java.exe

    Hi ,
    This thread is relevant to Oracle Java Compiler (file ojc) and jave.exe file.
    I have written a simple java program which consists of two simple simple classes and using the JDev's 10.1.3.2 ojc and java files , i'm trying to execute it after the successful compilation....
    The problem is that trying to run it... the error :
    Exception in thread "main" java.lang.NoClassDefFoundError: EmployeeTest
    appears.
    How can i solve this problem...????
    The program is as follows:
    import java.util.*;
    import corejava.*;
    public class EmployeeTest
    {  public static void main(String[] args)
       {  Employee[] staff = new Employee[3];
          staff[0] = new Employee("Harry Hacker", 35000,
             new Day(1989,10,1));
          staff[1] = new Employee("Carl Cracker", 75000,
             new Day(1987,12,15));
          staff[2] = new Employee("Tony Tester", 38000,
             new Day(1990,3,15));
          int i;
          for (i = 0; i < 3; i++) staff.raiseSalary(5);
    for (i = 0; i < 3; i++) staff[i].print();
    class Employee
    {  public Employee(String n, double s, Day d)
    {  name = n;
    salary = s;
    hireDay = d;
    public void print()
    {  System.out.println(name + "...." + salary + "...."
    + hireYear());
    public void raiseSalary(double byPercent)
    {  salary *= 1 + byPercent / 100;
    public int hireYear()
    {  return hireDay.getYear();
    private String name;
    private double salary;
    private Day hireDay;
    For compilation... i use :
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdev\bin\ojc -classpath D:\E-Book\Java\Sun_Java_Book_I\Corejava EmployeeTest.java
    For execution , i issue the command:
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    NOTE:I tried to use the jdk of Oracle database v.2 but the error :
    Unable to initialize JVM appeared....
    Thanks , a lot
    Simon

    Hi,
    Thanks god....
    I found a solution without using Jdev.....
    C:\oracle_files\Java\Examples>SET CLASSPATH=.;D:\E-Book\Java\Sun_Java_Book_I\Corejava
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\javac EmployeeTest.java
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    What does Ant has to do with this?Sorry, under the Ant tree a classpath label is found....I'm very new to Java and JDev...
    You need to include the jar file that has the Day method in it inside project properties->libraries.I have not .jar file.. just some .java files under the corejava directory.... By the way , I have inserted the corejava directory to the project pressing the button Add Jar/Directory.... , but the problem insists..
    Thanks , a lot
    Simon

Maybe you are looking for