• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IOException is never thrown error

 
Greenhorn
Posts: 7
Netbeans IDE Java ME Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my code sir, could you fix it?
i always get this error
Compiling 1 source file to E:\pelajaran\jeni\NetBeansProjects\TimerTask\build\compiled
E:\pelajaran\jeni\NetBeansProjects\TimerTask\src\MainMenu.java:57: exception java.io.IOException is never thrown in body of corresponding try statement catch(IOException ioe)

please sir...


 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

huzain ali wrote:This is my code sir, could you fix it?
i always get this error
Compiling 1 source file to E:\pelajaran\jeni\NetBeansProjects\TimerTask\build\compiled
E:\pelajaran\jeni\NetBeansProjects\TimerTask\src\MainMenu.java:57: exception java.io.IOException is never thrown in body of corresponding try statement catch(IOException ioe)



The compile error is pretty clear. It is located on line 57 of MainMenu.java. And it is complaining that you have a catch block that is trying to catch a checked exception that is never thrown. Hence, the compiler is complaining that the catch block code is *never* ran.

Seems pretty clear. What is it that you have an issue with?

Henry
 
huzain ali
Greenhorn
Posts: 7
Netbeans IDE Java ME Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please be sure to take the time to compose descriptive subjects for your posts. You will attract people who will can give you better and faster answers when your posts have good, descriptive subjects. For more information, please click this link ⇒ UseAMeaningfulSubjectLine.

Using a title such as "Help Me Please" isn't going to attract the attention of those who can best help you.

I have updated the subject for you -- please use it as a guide for future topics.



ok thanks sir, cz i'm newbie here...
 
huzain ali
Greenhorn
Posts: 7
Netbeans IDE Java ME Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The compile error is pretty clear. It is located on line 57 of MainMenu.java. And it is complaining that you have a catch block that is trying to catch a checked exception that is never thrown. Hence, the compiler is complaining that the catch block code is *never* ran.

Seems pretty clear. What is it that you have an issue with?

Henry



please fix my code, cz i don't know how to fix my code....
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

huzain ali wrote:

The compile error is pretty clear. It is located on line 57 of MainMenu.java. And it is complaining that you have a catch block that is trying to catch a checked exception that is never thrown. Hence, the compiler is complaining that the catch block code is *never* ran.

Seems pretty clear. What is it that you have an issue with?

Henry



please fix my code, cz i don't know how to fix my code....



That is *not* the policy on the ranch. The code ranch is a learning site -- we expect you to learn. And we only give hints in this regard. Given the fact, that you are asking about how to fix a compile issue, it may be a good idea to try out the Java tutorial.

http://docs.oracle.com/javase/tutorial/

If the issue is that you don't understand exceptions, that may be a good place to start. Or you can hop around the tutorial until you get comfortable.

Henry
 
huzain ali
Greenhorn
Posts: 7
Netbeans IDE Java ME Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That is *not* the policy on the ranch. The code ranch is a learning site -- we expect you to learn. And we only give hints in this regard. Given the fact, that you are asking about how to fix a compile issue, it may be a good idea to try out the Java tutorial.

http://docs.oracle.com/javase/tutorial/

If the issue is that you don't understand exceptions, that may be a good place to start. Or you can hop around the tutorial until you get comfortable.

Henry


ok, then what should i do with my try catch IOException? can i replace it with another code or anything?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

huzain ali wrote:
ok, then what should i do with my try catch IOException? can i replace it with another code or anything?



Just rephrasing the request doesn't work here. You need to explain what is it you are confused with, either with the error or with my first response, so that we can give you a hint. And if the issue is that you don't understand exceptions, then it is probably best to start with the tutorial posted earlier.

Henry
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic