How can I use a Java jar file in a Grails application?

After banging my head against the wall in trying to find out how I can use Java class in a Grails application I found out that the solution is embarrassing simple.

Just create a jar file from your Java classes and put the jar file into the folder “jar” of your Grails application.

You also have to add the correct import statement to your Groovy file. E.g. if you want to use class “MyJavaClass” in package “de.vogella.test” you have to add “import de.vogella.test.MyJavaClass” to your Groovy class.

You also need to re-start the grails server.

To learn more about Grails see Grails Tutorial

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Java, Web and tagged , . Bookmark the permalink.

One Response to How can I use a Java jar file in a Grails application?

  1. Pierre says:

    Thanks, you saved my day !

Comments are closed.