Netbeans:需要在classpath中包含第三方目录 [英] Netbeans: need to include 3'rd party directory in classpath

查看:174
本文介绍了Netbeans:需要在classpath中包含第三方目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在NetBeans中开发了一个基于NetBeans平台的应用程序。有一个第三方程序,我们有一个运行时依赖,更具体地说是其他progams lib文件夹中的一个jar。

We have an application developed in NetBeans, based on the NetBeans platform. There's a 3'rd party program that we have a runtime dependency on, more specifically a jar in the other progams lib folder.

我们应该如何包含其他程序的jar我们的类路径?

How should we include the other progam's jar in our classpath?

其他程序制造商的建议是将环境变量CLASSPATH设置为包含

The recommendation from the other progam's manufacturer is to set environment variable CLASSPATH to include

C:\Progam Files\Other Program\lib\theJAR.jar

如果那是不可能的,我们应该将theJAR.jar复制到 JRE-HOME \lib \ text

And if that's not possible, we should copy theJAR.jar to JRE-HOME\lib\ext

我们不能在任何其他地方复制JAR.jar,这可能会导致它停止工作......

We must not copy theJAR.jar anywhere else, that might cause it to stop working...

现在NetBeans不会注意环境变量CLASSPATH上的内容。他们推荐的方法似乎是制作一个包装器,但这会导致复制jar,除非有一些方法可以创建一个指向CLASSPATH的包装器模块?

Now NetBeans takes no notice of what's on environment variable CLASSPATH. Their recommended way seems to be to make a wrapper, but that would lead to copying the jar, unless there's some way to make a wrapper module that points to CLASSPATH?

目前我们正在将jar复制到 JRE-HOME \lib \ text 。但是当我们安装一些java更新时,就会有不必要的麻烦。

At the moment we are copying the jar into JRE-HOME\lib\ext. But then there's unnecessary hassle when we install some java update.

你有解决这个问题的方法吗?这看起来似乎很简单,但我还没找到合适的地方......

Do you have any solution to this problem? It seems like something that might be simple, but I haven't found the right place to look yet...

编辑:该应用程序是基于蚂蚁的。

The application is ant-based.

推荐答案

从Module System API的文档运行时基础结构概述(页面底部常见问题和解决方案一节) ):

From the documentation for the Module System API's overview of the runtime infrastructure (bottom of the page under the section "Common Problems and Solutions"):


Q :我的模块可以从$ b $外部的类路径中添加库JAR b IDE [读取:平台]安装?...

Q: Can my module add a library JAR to the classpath from outside the IDE [read: platform] installation?...

A :不容易。你有几个选择:

A: Not easily. You have a few options:


  1. 在ide.cfg [你的应用程序的.config文件]中添加一个条目。例如:

-cp:ac:\ eak \lib \ eak.jar 这启动文件提供了将类路径条目添加到IDE的Java调用的功能。

...

-cp:a c:\eak\lib\eak.jar This startup file provides the ability to add classpath entries to the IDE's Java invocation.
...

它去了列出另外两个选项。第二个选项与您提出的解决方案相同。第三个是对你的模块进行分区并使用一个新的类加载器,我无法推荐这两种方法,因为我没有这方面的经验(但值得一读)。

It goes on to list two more options. The second option is the same solution you've come up with. The third is to "partition your module and use a new classloader" which I can't recommend either way since I have no experience doing this (but it's worth a read).

假设您正在寻找第一个选项,请您需要添加自定义.conf将文件添加到项目中并指向project.properties文件中,如下所示: app.conf = nbproject / my.conf 。这会将您的自定义.conf文件添加到应用程序的安装目录,而不是通常添加的默认配置文件。当然,您需要将 -cp:ac:\ eak \lib \ eak.jar 条目添加到此自定义配置文件中才能加载.jar。

Assuming that this first option is what you are looking for, you will need to add a custom .conf file to your project and point to it in your project.properties file, like so: app.conf=nbproject/my.conf. This will add your custom .conf file to your app's install directory instead of the default config file that is normally added. Of course, you'll need to add the -cp:a c:\eak\lib\eak.jar entry to this custom config file in order to load the .jar.

在开发过程中,您需要将以下条目添加到project.properties文件中: run.args.extra = -cp :AC:\eak\lib\eak.jar 。这会将命令行选项传递给您的调试实例。

During development you'll need to add the following entry to the project.properties file: run.args.extra=-cp:a c:\eak\lib\eak.jar. This will pass the command line option to your debug instance.

这篇关于Netbeans:需要在classpath中包含第三方目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆