rcp classpath

Amit Rana wrote:

> Hello Mauro,
>   Thanks for responding.
>
>   I checked and all the required files (including the log4j.xml,
> hibernate.cfg.xml) are selected.
>
>   My app is not even recognising these files in PDE runtime.

If previously those libraries were finding those files automatically
through some relative path or your were telling the libraries where to
find those files using a relative path that relative path will now be
broken.  I do not know the API for those libraries from your example but
if you know how to tell those libraries where to find a config file you
can determine a real file system path to point them to.  Here is an
example that sets up the system property to find a .dll for JNI usage
(with non relevant code removed - so even though this comes from a working
system I have not compiled this exact snippet).

1 // Get the bundle object
2 Bundle bundle = MyPlugin.getDefault ().getBundle ();
3  
4 //  Find the lib directory
5 String libDirectoryPath = null;
6 URL bundleLocation = bundle.getEntry ("/lib");
7 try {
8  //  Resolve the URL
9  URL libURL = Platform.resolve (bundleLocation);
10  File libDirectory = new File (libURL.getFile ());
11  libDirectoryPath = libDirectory.toString ();
12
13  //  Add the lib directory to the system's library path
14  String systemLibraryPath = System.getProperty ("java.library.path");
15  StringBuffer newLibraryPath = new StringBuffer (libDirectoryPath);
16  newLibraryPath.append (File.pathSeparator).append (systemLibraryPath);
17  System.setProperty ("java.library.path", newLibraryPath.toString());
18 }  catch (Exception e)  {
19  // Report the problem some how
20 }

At line 6 the path for getEntry is relative to your plug-in's root.  So
your congif files need to be in a top level directory under your plug-in. 
After you resolve your location as in line 9 the URL now points to the
file in a way that will allow you to get a file path. 

Ian

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值