Results 1 to 2 of 2
- 07-31-2007, 04:15 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
Error: java.lang.InterruptedException is not caught and does not appear...
Hi, I have a simple program like:
And I'm using .NET to compile which is fine. However, the result screen just appears for 0.1 seconds. I've used the system("Pause") when programming in C++.Java Code:package pckg; public class HelloWorldApp { public static void main (String args[]) { System.out.println ("Hello World!"); } }
I tried Thread.Sleep(500) right after "System.out.println("Hello World!") but get this errorWhat is the equivalent call in java?Java Code:Exception 'java.lang.InterruptedException' is not caught and does not appear in throws clause.
Thanks.Last edited by fernando; 07-31-2007 at 04:17 AM.
- 07-31-2007, 05:52 AM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
You can do one of two things. 1. Run your program from a command prompt. This way the prompt will not go away. 2. change your code to the following:
This is kind of cheeky but if lets you forgo the try catch block round the thread sleep call.Java Code:package pckg; public class HelloWorldApp { public static void main (String args[]) throws Exception { System.out.println ("Hello World!"); Thread.sleep(500); } }
Similar Threads
-
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String)
By baltimore in forum New To JavaReplies: 2Last Post: 09-18-2008, 07:30 AM -
Error: cannot be applied to (java.lang.String)
By carl in forum New To JavaReplies: 1Last Post: 08-05-2007, 06:33 AM -
Cast Error Caught (change) Class is really: java.lang.String
By barney in forum Advanced JavaReplies: 1Last Post: 08-02-2007, 04:07 PM -
Error: java.lang.ArrayIndexOutOfBoundsException
By fernando in forum Java 2DReplies: 1Last Post: 07-31-2007, 11:47 PM -
Error Java.lang.NullPointerException in JBuilder2006
By Jack in forum Other IDEsReplies: 2Last Post: 07-02-2007, 02:29 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks