![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jun 2005
Posts: 34
Rep Power: 0
![]() |
Run-Time Complications/Errors
Here's the code:
import java.util.*;
public class FirstProgram
{
public static void main(String[] args)
{
System.out.println("Hello out there.");
System.out.println("I will add two numbers for you.");
System.out.println("Enter two whole numbers on a line:");
int n1, n2;
Scanner keyboard = new Scanner(System.in);
n1 = keyboard.nextInt( );
n2 = keyboard.nextInt( );
System.out.println("The sum of those two numbers is");
System.out.println(n1 + n2);
}
}What kind of errors are those? I'm just completely puzzled. I'd like to know what I'm doing wrong. This again is a program from my book, and it appears to be 100% correct to me. No errors or anything in there. Well, of course not, because it compiles fine. But whenever I try to run it, from within UltraEdit32, that is, I get these errors down in the output window. ODDLY, when I do everything in a dos prompt window, like using the "java" command to run it... it runs just fine! No errors at all. This probably has something to do with UltraEdit. I'd just like to know what's up ![]() Thanks Last edited by cscgal; Oct 18th, 2007 at 9:18 AM. Reason: Removed broken attachment |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
I think it is either because you did not enter a value or entered a character?
its looking for an int but finding nothing therefore make sure you put a int into the console, or put some error correction in there.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jun 2005
Posts: 34
Rep Power: 0
![]() |
No the thing is... this only happens in UltraEdit32. When I type "java" in the command-prompt to manually run this, it runs without any errors. Only within UE32 do I get this bunch of errors, and I have no idea why
![]() I'll try posting over at the UE32 forums maybe. It's more of an editor-specific problem than it is a Java coding problem. |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
the Scanner class was introduced in 1.5... maybe the IDE you are using doesn't support the 1.5 features yet?
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jun 2005
Posts: 34
Rep Power: 0
![]() |
I'm using nothing but a text editor. UltraEdit32. The rest is plain vanilla Java JDK 5.0. I have no IDE.
|
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Perhaps the current directory is wrongly set in the UltraEdit interface - this causes problems with many compilers.
|
|
|
|
|
|
#7 |
|
Professional Programmer
|
I haven't used UltraEdit, but can you input numbers when you run your program? Does a DOS window apear? or does it run in UltraEdit.
If it runs in UltraEdit, maybe you can't give any input and that's why it dies.
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
I haven't used UltraEdit either (I use TextPad), and that has the possiblity to capture output so no 'dos box' pops up.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|