Depends on the IDE.Will it even let it ...
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Depends on the IDE.Will it even let it ...
javapenguin (June 17th, 2010)
Why is it even asking the user to, repeatedly too unfortunately, to enter the size of the grid? I never told it to do that in the exception, did I?
Enter a value that is an integer, i.e. not a decimal
java.util.InputMismatchException
Enter the size of the grid.
I knew it! You have a ghost that is changing your code when you turn your head.
You must enter the type of data that the program expects.InputMismatchException
And the program MUST handle ANY user input.
javapenguin (June 17th, 2010)
Look at this code. Make a small test program and execute it. Enter chars vs digits sometimes.
try { System.out.print("Enter an integer:"); int x = s.nextInt(); System.out.println("got x=" + x); }catch(InputMismatchException x) { System.out.println("error " + x); String ln = s.nextLine(); // remove the invalid stuff System.out.println("ln=" + ln); } try { System.out.print("Enter another integer:"); int x = s.nextInt(); System.out.println("got x1=" + x); }catch(InputMismatchException x) { System.out.println("error1 " + x); String ln = s.nextLine(); // remove the invalid stuff System.out.println("ln1=" + ln); } }
javapenguin (June 17th, 2010)
How will it know which x you're talking about?
int x = s.nextInt();
InputMismatchException x
System.out.println("error " + x);
Also, it will run exceptions, it just keeps going, i.e.
InputMismatchException
InputMismatchException
InputMismatchException
InputMismatchException
etc
It probably is because I'm having it do everything all over as I have the option to play again.
Unless, do you mean my stuff like this:
String ln = s.nextLine() should be removed?
Did you try my code in a program?
javapenguin (June 17th, 2010)
Not yet, but I figured out that it's only the Input Mismatch Exception that's causing the problem. The other two Eclipse claims are causing errors aren't. Actually, I see what you meant, though how come I didn't need to have console.nextLine for my two other exceptions?
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\Paul>java -jar battleship2.jar
Unable to access jarfile battleship2.jar
And now:
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\Paul\Documents>java -jar battleship game 2.jar
Unable to access jarfile battleship
C:\Users\Paul\Documents>java -jar battleship2.jar
Invalid or corrupt jarfile battleship2.jar
C:\Users\Paul\Documents>
Ok, code works now but still won't open. I told the desktop application to open with command prompt.
The java program doesn't like your jar file.C:\Users\Paul\Documents>java -jar battleship2.jar
Invalid or corrupt jarfile battleship2.jar
Can you open it using a program that can read zip files and see if its corrupted?
If you can open it, look at the manifest file and see if it is formated correctly.
javapenguin (June 18th, 2010)
It may possibly be corrupted, but it does like it when I enter the name of the file in the command prompt or something like that, though it only shows the copyright.
I used Eclipse.
Do you have a program that can open a zip file?Can you open it using a program that can read zip files and see if its corrupted?
If you can open it, look at the manifest file and see if it is formated correctly.
I might. Name some that will. Actually I do, but don't know their names.
On WinXP XP will open zip files. Rename the file by adding .zip to the end.
javapenguin (June 18th, 2010)
I have Vista.
Try it. No idea how vista works.
javapenguin (June 18th, 2010)
Anyway, is there way to make these jars so they can be sent to others more easily instead of running into a lot of technical errors sending them in email?
And is it possible to create a class that has one, undefined, JButton, or better, yet has an int in the constructor that determines the number of JButtons created, and a thing in the constructor to make a JScrollPane with a JTextArea and at least one JMenu that would create an int number of JMenuItems with another int number of submenuitems all in the constructor?
It will be class JComboPane.