This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling java program from groovy...

 
Ajay Vikas
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to groovy language. How can i integrate and call java programs or create instances from groovy script.

Please help me over this.

Thanks,
Vikas.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Dierk König
author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas,
you do exactly the same as you would do in Java, e.g.



or did I misunderstand your question?

cheers
Dierk
 
Ajay Vikas
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dierk,

Thank you for your quick reply.
I need an example where i can call a java program from groovy script. I tried with a sample example it is throwing unable to resolve class name. So please help me in loading of java class while executing groovy script. I am not sure of setting classpath for groovy examples. Please advice.

Thanks,
Vikas.
 
Dierk König
author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by

call a java program

?
Instantiating a Java class? Calling a method? Calling a main method?

How would you do the exactly same from Java code?

cheers
Dierk
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the error you were talking about?
http://www.coderanch.com/t/55/Groovy/Eclipse-IDE-errors-when-compile

If so, which classes are your Java classes? It's not the Build and Component domain classes is it? I'm pretty sure Grails expects your domain classes to be Groovy.

It might be best to start your learning by trying to mix Java with Groovy in a realm that makes more sense than the primary components of a Grails app.
 
Ajay Vikas
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all. I could able to instantiate the java object in groovy script. This is as similar as Java object instantiation in eclipse.

Yep thats true that was the error i am talking about. Getting the domain groovy script not found. I am started with the java object creation in groovy. So i need to debug this error too.

Thank you !!!

--
Ajay Vikas.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic