Results 1 to 6 of 6
  1. #1
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default Main method throwing specific Exception

    The following signature of main method works fine.

    Java Code:
              public static void main(String[] args) throws Exception {
    When I try to use some specific Exception, main method throws exception.

    Java Code:
    	public static void main(String[] args) throws IOException {
    Exception:
    Java Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    	IOException cannot be resolved to a type

  2. #2
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Strange

    Hello bugger

    I find this very strange, but unfortunately I can't help you. I just want to know why you want your main() method to throw exceptions. You should catch and handle them ultimately in your main() method if you keep throwing them. ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    This works okay.
    Java Code:
    public class Test {
        public static void main(String[] args) throws java.io.IOException {
            
        }
    }

  4. #4
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    Location
    New York
    Posts
    143
    Rep Power
    0

    Default

    Yeah, whenever you see "(something) cannot be resolved to a type" you didn't import it, or it doesn't exist.

  5. #5
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    ofcourse import is the solution or use fully qualified name

  6. #6
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Zombie alert

    ron87... pay attention... your answering a post that is over a year old. If needed, open a new thread.

    Thanks,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  2. Main method with throws Exception
    By bugger in forum New To Java
    Replies: 3
    Last Post: 01-07-2008, 02:48 PM
  3. throwing Exception
    By bugger in forum New To Java
    Replies: 3
    Last Post: 11-09-2007, 09:35 PM
  4. Replies: 1
    Last Post: 08-07-2007, 07:10 AM
  5. Replies: 1
    Last Post: 08-06-2007, 09:11 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
  •