简体   繁体   English

如何在Notes Xpages应用程序中添加外部第三方jar?

[英]How to add external third party jar in Notes Xpages application?

I am Java developer, recently working on Xpages project. 我是Java开发人员,最近从事Xpages项目。 we are using Notes 9.0.1. 我们正在使用Notes 9.0.1。 I created Java agent to send email and I want to use some third party jar, something like org.apache.commons.lang3 , end up this issue. 我创建了Java代理来发送电子邮件,并且我想使用一些第三方jar(例如org.apache.commons.lang3)来解决此问题。 how to add third party jar, like commons-lang3-3.4.jar, in my Xpages project? 如何在我的Xpages项目中添加第三方jar,例如commons-lang3-3.4.jar?

I tried different ways 我尝试了不同的方式

  1. add jar under /jvm/lib/ext folder, restart DDE.the I can see it in my project JRE system libray, but could not import in my Java code. 在/ jvm / lib / ext文件夹下添加jar,重新启动DDE。我可以在我的项目JRE系统libray中看到它,但是无法导入我的Java代码。 Maybe this is the way for server deployment. 也许这是服务器部署的方式。
  2. add jar under /Code/Jars and then DDE generated with new name added in /Webcontent/WEB-INF/lib, but... 在/ Code / Jars下添加jar,然后在/ Webcontent / WEB-INF / lib中添加以新名称生成的DDE,但是...
  3. Add jar directly under /Webcontent/WEB-INF/lib, but not appeared /Code/Jars in Application view 将jar直接添加到/ Webcontent / WEB-INF / lib下,但未出现在“应用程序”视图中的/ Code / Jars
  4. add jar under the Java agent Archive folder, but... 在Java代理的Archive文件夹下添加jar,但是...

None of them allows me import the package in my Java code. 它们都不允许我将包导入到Java代码中。

Anything I did wrong, or is there any good way to add third party jar in XPages project. 我做错了什么,或者是否有任何好的方法在XPages项目中添加第三方jar。

Thanks 谢谢

If you add a JAR to your project by importing it into /Code/JARs , it should be added so as to be accessible by your build path(2,3). 如果通过将JAR导入到/ Code / JARs中而将其添加到项目中,则应将其添加到构建路径(2,3)中。 The same is true of your /WebContent/WEB-INF/lib , but that may not be automatically defined in your version of DDE; / WebContent / WEB-INF / lib也是如此,但是在您的DDE版本中可能不会自动定义。 for example, Domino Designer 9 has the design elements of /Code/Java and /Code/JARs , which didn't previously exist (these are separate folders/paths from /WebContent/WEB-INF/src or /WebContent/WEB-INF/lib , either can be in the build path). 例如,Domino Designer 9具有/ Code / Java/ Code / JARs的设计元素,这些元素以前不存在(这些是/ WebContent / WEB-INF / src/ WebContent / WEB-INF的单独文件夹/路径/ lib ,都可以在构建路径中)。 In either case, if your approach is to have the JAR in your NSF, make sure your build path has the path with your JARs. 无论哪种情况,如果您的方法是在NSF中包含JAR,请确保构建路径具有JAR的路径。 Separately you could add each JAR individually. 您可以单独添加每个JAR。

You can get to the Build Path via Project > Properties, then for the part of your build path concerning JARs, go to "libraries": 您可以通过“项目”>“属性”进入“构建路径”,然后对于构建路径中有关JAR的部分,转到“库”:

individual JARs in Project Build Path 项目构建路径中的各个JAR 项目构建路径中的各个JAR

JAR class path in Build Path (ex- /WebContent/WEB-INF/lib) 构建路径中的JAR类路径(例如-/ WebContent / WEB-INF / lib) JAR类路径

As for the path of using the /jvm/lib/ext folder approach, I've covered that in a blog post and it's important to remember to have the JARs in the appropriate relative path both on the server and in your Designer /local path (otherwise your local, DDE, may not pick up the change).(1) 至于使用/ jvm / lib / ext文件夹方法的路径,我已经在博客文章中介绍了这一点,请务必记住在服务器和Designer / local路径中的相应相对路径中具有JAR。 (否则,您的本地DDE可能无法接收更改)。(1)

For both, if you keep build automatically turned off, you'll want to make sure you perform another build to see the changes. 对于这两者,如果您保持构建自动关闭,则需要确保执行另一个构建以查看更改。

As for a Java Agent archive, this should just work and again I'm wondering whether your build automatically setting is enabled/disabled. 至于Java Agent存档,这应该可以正常工作,我想知道您的构建自动设置是否启用/禁用。 The /jvm/ext/lib path ought to work for this as well (shown in my linked blog post).(4) *Note: as Paul Withers points out in the comments , importing a JAR to a Java Agent can introduce memory leak issues, making the /jvm/ext/lib/ path preferable. / jvm / ext / lib路径也应该对此起作用(显示在我的链接博客文章中)。(4)*注意: 正如Paul Withers在评论中指出的那样 ,将JAR导入Java Agent可能会导致内存泄漏。问题,使/ jvm / ext / lib /路径更可取。

Java Agent档案包含

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

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