Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 05:15 AM
Member
 
Join Date: Jul 2007
Posts: 40
fernando is on a distinguished road
Error: java.lang.InterruptedException is not caught and does not appear...
Hi, I have a simple program like:

Code:
package pckg; public class HelloWorldApp { public static void main (String args[]) { System.out.println ("Hello World!"); } }
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++.

I tried Thread.Sleep(500) right after "System.out.println("Hello World!") but get this error
Code:
Exception 'java.lang.InterruptedException' is not caught and does not appear in throws clause.
What is the equivalent call in java?
Thanks.

Last edited by fernando : 07-31-2007 at 05:17 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 06:52 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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:
Code:
package pckg; public class HelloWorldApp { public static void main (String args[]) throws Exception { System.out.println ("Hello World!"); Thread.sleep(500); } }
This is kind of cheeky but if lets you forgo the try catch block round the thread sleep call.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String) baltimore New To Java 1 08-06-2007 08:45 AM
Error: cannot be applied to (java.lang.String) carl New To Java 1 08-05-2007 07:33 AM
Cast Error Caught (change) Class is really: java.lang.String barney Advanced Java 1 08-02-2007 05:07 PM
Error: java.lang.ArrayIndexOutOfBoundsException fernando Java 2D 1 08-01-2007 12:47 AM
Error Java.lang.NullPointerException in JBuilder2006 Jack Other IDEs 2 07-02-2007 03:29 AM


All times are GMT +3. The time now is 02:16 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org