Results 1 to 2 of 2
  1. #1
    fernando is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Error: java.lang.InterruptedException is not caught and does not appear...

    Hi, I have a simple program like:

    Java 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
    Java 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.

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    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:
    Java 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.

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2008, 08:30 AM
  2. Error: cannot be applied to (java.lang.String)
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 07:33 AM
  3. Replies: 1
    Last Post: 08-02-2007, 05:07 PM
  4. Replies: 1
    Last Post: 08-01-2007, 12:47 AM
  5. Replies: 2
    Last Post: 07-02-2007, 03:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •