wood burning stoves 2.0*
The moose likes Groovy and the fly likes Calling java program from groovy... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Calling java program from groovy..." Watch "Calling java program from groovy..." New topic
Author

Calling java program from groovy...

Ajay Vikas
Ranch Hand

Joined: Nov 08, 2006
Posts: 66
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

Joined: Feb 27, 2002
Posts: 8919

Yes


Groovy
Dierk König
author
Ranch Hand

Joined: Nov 01, 2006
Posts: 43
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

Joined: Nov 08, 2006
Posts: 66
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

Joined: Nov 01, 2006
Posts: 43
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

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
Ajay Vikas
Ranch Hand

Joined: Nov 08, 2006
Posts: 66
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.
 
wood burning stoves
 
subject: Calling java program from groovy...