简体   繁体   English

如何使用 Java 包与 Groovy

[英]How to use Java packages with Groovy

I'm at school and we are doing this java stuff.我在学校,我们正在做这个 java 的事情。 We use a special library named sum.kern: http://www.mg-werl.de/sum/bjw.zip我们使用一个名为 sum.kern 的特殊库: http://www.mg-werl.de/sum/bjw.zip

I want to use Groovy instead of Java. But I can't get groovy to use this library.我想使用 Groovy 而不是 Java。但我无法获得 groovy 来使用这个库。 If I add the jar in grape and try to import sum.kern and create a sum.kern.Bildschirm it says that it is not able to find it.如果我在 grape 中添加 jar 并尝试导入 sum.kern 并创建一个 sum.kern.Bildschirm,它会说无法找到它。 How to do it?怎么做?

I don't think it should be a problem, its pretty straight forward.我不认为这应该是一个问题,它非常简单。 The only requirement is to have the library in your classpath.唯一的要求是将库放在类路径中。

Are you able to import the package successfully?你能成功导入package吗?

It doesn't matter though, What IDE are you using, BTW?不过没关系,顺便说一句,您使用的是什么 IDE?

You should have a "groovy-starter.conf" file that specifies the directories in which groovy looks for jar files.您应该有一个“groovy-starter.conf”文件,它指定 groovy 在其中查找 jar 文件的目录。 It should be in the "conf" directory within groovy.home (for example, on my machine it is "C:\groovy\Groovy-1.5.6\conf\groovy-starter.conf").它应该在 groovy.home 中的“conf”目录中(例如,在我的机器上它是“C:\groovy\Groovy-1.5.6\conf\groovy-starter.conf”)。

If the jar file containing the classes you want to import are within one of these directories, you should be able to import it no problem.如果包含您要导入的类的 jar 文件在这些目录之一中,您应该可以毫无问题地导入它。 Alternatively, you could add the directory that the jar is currently in to your groovy-starter.conf file.或者,您可以将 jar 当前所在的目录添加到 groovy-starter.conf 文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM