Dear Expert: Below I have included a simple DO WHILE loop. Occasionally when I try to exit the loop it says batch file missing and re-enters the loop. I have the code from the main method as well as the output when the error occurs.
import corejava.*; //This is for the Console.read class cyrptograph { public static void main (String args[]) { char quit; do { System.out.println ("Enter 1 to encode a message"); System.out.println ("Enter 2 to decode a message"); int resp = Console.readInt ("enter choice:"); if ( resp == 1) encode(); else decode(); String response = Console.readLine ("Enter C to continue or Q to quit"); quit = response.charAt(0); } while (quit == 'C' | | quit == 'c'); System.out.println ("Goodbye"); } //end of main
This problem only happens periodically, but here is output I get when it happens:
Enter C to continue or Q to quit q Goodbye Batch file missing C:\JavaPro\Practice\DosApp\Cryptography> Enter 1 to encode a message Enter 2 to decode a message enter choice:
You can see how it prints "Goodbye" which means it has exited the DO WHILE loop, yet it somehow ends up back in the loop. Does anyone know why?
Chad McGowan
Ranch Hand
Joined: May 10, 2001
Posts: 265
posted
0
How do you invoke this program? Do you use java from the command prompt?
Tim Barker
Greenhorn
Joined: Aug 03, 2001
Posts: 24
posted
0
No I use TextPad, but I am sure I could find the same problem from the command prompt.
Metal Zhang
Ranch Hand
Joined: Aug 05, 2001
Posts: 52
posted
0
The error message "Batch file missing" is defined by yourself? I think maybe you can convert your definition of 'char quit' to 'String quit',and do like this: do{ ........ String quit; quit = response.subString(0,1); ........ }while(quit.equals("C") | | quit.equals("c")) ------------------ Java lover from hell!
Java lover from hell!
Tim Barker
Greenhorn
Joined: Aug 03, 2001
Posts: 24
posted
0
That makes sense. I never defined "Batch file missing", but it is probably part of the Corejava that I imported. The Corejava is from the book of the same name that included a CD-ROM that allows you to input information with the Console.line command and probably took exception to how I used it. I can check the files to see if that is a exception that it throws. Thanks
Chad McGowan
Ranch Hand
Joined: May 10, 2001
Posts: 265
posted
0
Originally posted by Tim Barker: No I use TextPad, but I am sure I could find the same problem from the command prompt.
Have you tried it from the command prompt? The reason I'm asking is to find out where this "batch file" error message is coming from.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.