开发者

Can a groovy code be compiled to run in JRE?

I am new to groovy and I cannot understand, if it is possible to compile a groovy program, so it runs at all computers, were the JRE is installed.

The application I am developing has to run on any computer with JRE 1.5. Is it possible to start using groovy and maintain this flexibility? With JRE 1.6?

I have heard about the library groovy-all-VERSION.jar. Is this the one require开发者_如何学运维d library to be shipped with my application?


The answer is yes. In fact, all groovy code compiles down to Java classes that run on the JRE. All you need is JRE 1.4 or higher and the groovy-all-*.jar on the classpath of your application.

Since you are looking to support JRE 1.5 or higher, make sure your source compatibility is set on your compiler to this level.

There are a few options for compiling your groovy code. Groovyc (Ant Task), GMaven (Maven) and Gradle are all options.

Another option you have is to 'not' compile your groovy code. The groovy distribution only requires the JRE to be installed. You can ship your application as a set of scripts that can simply be run using the groovy install. It depends on how sensitive your source code is.


The short answer is yes. How you do this depends on your build system. I do all my development in eclipse, right click my project, select export, select runnable jar file, and all the required librarys are exported in the jar file. I can then run this file on a machine with out Groovy installed. I know build systems like Maven support Groovy but don't know the details on how they do it or how good there support is. According to this question Java 1.4 or above is fine. When looking at the "Setting up your Java environment" section of the initial tutorial it looks like you need Java 1.5 installed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜