Eclipse 3.4 - external JARs with environment variables

半腔热情 提交于 2019-12-24 07:13:07

问题


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.

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.

Is there any way to use Windows environment variables for the classpath definition of eclipse plug-ins? 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...


回答1:


No, Bundle-ClassPath is not used this way. 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.




回答2:


external: is an Eclipse containerism. But I think you need to prefix each external jar with external:. Also, IBMCMROOT must be a system property (not an environment variable). For example, start java with -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.



来源:https://stackoverflow.com/questions/19546611/eclipse-3-4-external-jars-with-environment-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!