• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception object not supported by println method

 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.ArithmeticException: / by zero


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 ?
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic