Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 8th, 2005, 3:58 AM   #1
shangnyun
Programmer
 
shangnyun's Avatar
 
Join Date: Jun 2005
Posts: 34
Rep Power: 0 shangnyun is on a distinguished road
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
shangnyun is offline   Reply With Quote
Old Jun 8th, 2005, 5:06 AM   #2
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Old Jun 8th, 2005, 5:33 AM   #3
shangnyun
Programmer
 
shangnyun's Avatar
 
Join Date: Jun 2005
Posts: 34
Rep Power: 0 shangnyun is on a distinguished road
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.
shangnyun is offline   Reply With Quote
Old Jun 9th, 2005, 10:31 AM   #4
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
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
skuinders is offline   Reply With Quote
Old Jun 9th, 2005, 10:33 AM   #5
shangnyun
Programmer
 
shangnyun's Avatar
 
Join Date: Jun 2005
Posts: 34
Rep Power: 0 shangnyun is on a distinguished road
I'm using nothing but a text editor. UltraEdit32. The rest is plain vanilla Java JDK 5.0. I have no IDE.
shangnyun is offline   Reply With Quote
Old Jun 9th, 2005, 10:53 AM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Perhaps the current directory is wrongly set in the UltraEdit interface - this causes problems with many compilers.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 9th, 2005, 12:21 PM   #7
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 381
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
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 !
xavier is offline   Reply With Quote
Old Jun 9th, 2005, 12:53 PM   #8
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC