• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Caught: java.lang.ExceptionInInitializerError while calling java class from Groovy

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Class:


----------------------------------------------------------------------------

Groovy:

-------------------------------------------------------------------------------------

output is :
1
2
Lars
4
Caught: java.lang.ExceptionInInitializerError
at com.FirstGroovy.main(FirstGroovy.groovy:11)


-------------------------------------------------

IDE: Jboss developer studio Version: 7.1.0.GA
JDK: jdk1.8.0_121



 
Marshal
Posts: 69411
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added code tags to your post, and doesn't it look better Always use the tags; there is even a dropdown list so you can choose highlighting for Groovy. Please copy'n'paste code onto this website; the line numbers appear to be different from what the stack trace shows.
I don't know any Groovy, but I can't see anywhere that would throw that sort of exception. That type of exceptionis thrown from static initialisers, and you haven't got any static initialisers. Try changing the Groovy to read thus:-and create another Java® classSee what happens. I know it is naughty to have that sort of code in a constructor, but it will allow you to see what is happening in the Java® without altering too much of the Groovy. I added a main method so you can try the Java® code on its own.
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic