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 01-21-2008, 06:47 PM
Senior Member
 
Join Date: Nov 2007
Posts: 111
bugger is on a distinguished road
Main method throwing specific Exception
The following signature of main method works fine.

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

Code:
public static void main(String[] args) throws IOException {
Exception:
Code:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: IOException cannot be resolved to a type
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-21-2008, 06:57 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
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.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-21-2008, 08:06 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,144
hardwired is on a distinguished road
This works okay.
Code:
public class Test { public static void main(String[] args) throws java.io.IOException { } }
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-22-2008, 04:08 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
Yeah, whenever you see "(something) cannot be resolved to a type" you didn't import it, or it doesn't exist.
__________________
//Haha javac, can't see me now, can ya?
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
Trouble with factory method - unhandled exception type Exception desmond5 New To Java 1 03-08-2008 07:41 PM
Main method with throws Exception bugger New To Java 3 01-07-2008 03:48 PM
throwing Exception bugger New To Java 3 11-09-2007 10:35 PM
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main barney New To Java 1 08-07-2007 08:10 AM
exception in thred main java.lang.nosuchmethoderror: main fernando Java Applets 1 08-06-2007 10:11 AM


All times are GMT +3. The time now is 10:43 PM.


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