简体   繁体   English

Eclipse 3.4-具有环境变量的外部JAR

[英]Eclipse 3.4 - external JARs with environment variables

I am developing a Plug-in for Lotus Notes (which is Eclipse 3.4) and need to rely on an external SDK/Connector for some Java dependencies and also Configuration files. 我正在开发Lotus Notes插件(它是Eclipse 3.4),并且需要依赖外部SDK / Connector来获取一些Java依赖关系以及配置文件。

It seems that in order to function properly, a file from the Connector installation folder has to be in the classpath. 为了正常运行,似乎连接器安装文件夹中的文件必须位于类路径中。 Since I don't know where it's installed, I have to rely on an environment variable that is set during installation ("IBMCMROOT"), which contains the folder. 由于我不知道它的安装位置,因此我不得不依赖安装期间设置的环境变量(“ IBMCMROOT”),该变量包含文件夹。

Is there any way to use Windows environment variables for the classpath definition of eclipse plug-ins? 有什么方法可以将Windows环境变量用于Eclipse插件的类路径定义? I've tried using variables in the manifest: 我试过在清单中使用变量:

Bundle-ClassPath: external:$IBMCMROOT$/lib/cmb81.jar,
 $IBMCMROOT$/lib/cmbsdk81.jar,
 $IBMCMROOT$/lib/db2jcc.jar,
 .,
 $IBMCMROOT$/lib/guava-15.0.jar,
 $IBMCMROOT$/lib/log4j-1.2.17.jar

This results in ClassNotFoundExceptions... 这导致ClassNotFoundExceptions ...

No, Bundle-ClassPath is not used this way. 不,不是通过这种方式使用Bundle-ClassPath。 It can only refer to paths within the bundle itself. 它只能引用包本身内的路径。

In order to load classes from an arbitrary external JAR file at an unknown location, you will need to use a URLClassLoader . 为了从未知位置的任意外部JAR文件加载类,您将需要使用URLClassLoader

external: is an Eclipse containerism. external:是Eclipse容器主义。 But I think you need to prefix each external jar with external: . 但是我认为您需要在每个外部jar前面加上external: :。 Also, IBMCMROOT must be a system property (not an environment variable). 另外, IBMCMROOT必须是系统属性(不是环境变量)。 For example, start java with -DIBMCMROOT=... 例如,使用-DIBMCMROOT=...启动Java -DIBMCMROOT=...

However, I would not do this. 但是,我不会这样做。 Instead, put these necessary jars on the classpath and configure the system bundle to export those package which you can then import from your bundles. 而是将这些必要的jar放在类路径上,并配置系统捆绑包以导出那些包,然后可以从捆绑包中导入这些包。

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

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