Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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: 64494
225
  • 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.
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!