0

I have existing java web application. Now I have written a groovy hello world class. How should I compile it with existing java class? From http://groovy.codehaus.org/ looks like I need a different compiler for this as command is groovy -e "println 'Hello ' + args[0]" World instead use javac.

I want to compile command from both command prompt and eclipse so that groovy class gets compiled with existing java classes.

0

2 Answers 2

5

You need to use joint compilation in Groovy, to attach javac compiler to compile .java files.

Use -j option with groovyc compiler:

groovyc *.groovy *.java -j
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Arturo Herrero. Actually i am interested other way around. i mean want to attach groovy compiler to compile groovy files as i have hundread of existing java file and only one groovy file. What modification i need to do in eclipse compilation setting to also compile new groovy file.
Sorry, I mainly use command line and Sublime text editor. I can't help you with the Eclipse configuration.
2

If you're building with Eclipse I guess you need to install the Groovy plugin and make sure it is seeing your project as a groovy project.

I'm not sure how to do this, as like Arturo, I just use Sublime Text and the command line.

For compiling from the command line, you should be using something like Ant (documentation can be found here for the groovyc task and cross-compiling with Java), or Gradle (documentation here on the Groovy plugin)

1 Comment

Yes. Install plugin and add Groovy nature to the product in the preferences

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.