| Author |
Exception object not supported by println method
|
Raman Ghai
Ranch Hand
Joined: Jan 01, 2012
Posts: 51
|
|
Hi there,
I have created a simple java program as shown below:
I should get an exception . However Netbeans IDE gives the following error on line 11 :
Netbeans IDE version : 7.0.1
JDK version : jdk1.6.0_03
Please help me resolve this error....
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5875
|
|
You've either got a corrupt installation or a messed up configuration. What happens when you compile on the command line?
|
 |
Raman Ghai
Ranch Hand
Joined: Jan 01, 2012
Posts: 51
|
|
Jeff Verdegan wrote:You've either got a corrupt installation or a messed up configuration. What happens when you compile on the command line?
No errors at compilation
Exception at runtime : java.lang.ArithmeticException: / by zero
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5875
|
|
Parminder Ghai wrote:
Jeff Verdegan wrote:You've either got a corrupt installation or a messed up configuration. What happens when you compile on the command line?
No errors at compilation
Exception at runtime : java.lang.ArithmeticException: / by zero
Then there's something wrong with your NB installation or configuration.
|
 |
Raman Ghai
Ranch Hand
Joined: Jan 01, 2012
Posts: 51
|
|
Jeff Verdegan wrote: Then there's something wrong with your NB installation or configuration.
That's what I want to figure out . Should I update the JDK?
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5875
|
|
Parminder Ghai wrote:
Jeff Verdegan wrote: Then there's something wrong with your NB installation or configuration.
That's what I want to figure out . Should I update the JDK?
I don't know. I cant see your system, and I'm not a NB expert. The JDK appears to be fine, so more likely you should reconfigure or reinstall NB. However, it may be that updating the JDK and then pointing NB at that new JDK will cure it of whatever problems it's having with its configuration.
|
 |
Raman Ghai
Ranch Hand
Joined: Jan 01, 2012
Posts: 51
|
|
Jeff Verdegan wrote: it may be that updating the JDK and then pointing NB at that new JDK will cure it of whatever problems it's having with its configuration.
It actually worked . I downloaded the new JDK and changed the project libraries .
Thanks for replying ..
|
 |
Chandraprakash Sarathe
Greenhorn
Joined: Jan 21, 2012
Posts: 16
|
|
Class ArithmeticException doesn't override toString() method, then how come message "/ by zero" gets printed ? Can anyone explain this ?
Is it the method toString() from Throwable gets called ?
|
Chandraprakash Sarathe
http://javaved.blogspot.com
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Indeed, and this returns the class name followed by a colon and the exception's message from its toString() method (or just the class name if there is a null message). This message ("/ by zero") is set by the JVM when it encounters an integer division by 0.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
You will have to learn your way around the API documentation. If you click on that link for the exception you quoted, you find “toString” under the heading of inherited from Throwable,
|
 |
 |
|
|
subject: Exception object not supported by println method
|
|
|