1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public void start(BundleContext context) {
try{
super.start(context);
} catch (Exception e) {
logInfo("error catched: "+e.getMessage());
}
String path;
// build OJAWA path
String os = java.lang.System.getProperty("os.name");
if(os.equals("Linux")){
path = FileLocator.toFileURL(FileLocator.find(context.getBundle(), new Path("/"), null)).getPath();
path = path + "/libotawa/lib/libojawa.so";
}
else if(os.startsWith("Windows")){
//path = FileLocator.toFileURL(FileLocator.find(context.getBundle(), new Path(""), null)).getPath();
//path = path + "libotawa/lib/libojawa.dll";
URL urlVersDll;
try {
urlVersDll = new URL(FileLocator.find(context.getBundle(), new Path(""), null),"libotawa/lib/libojawa.dll");
File fichier;
fichier = new File(urlVersDll.toURI());
path = fichier.getAbsolutePath();
} catch (URISyntaxException e) {
logInfo("error catched: "+e.getMessage());
e.printStackTrace();
} catch (MalformedURLException e) {
logInfo("error catched: "+e.getMessage());
e.printStackTrace();
}
}
else {
path = null;
ADTREEPlugin.logError("unsupported OS: OTAWA library shouldn't be accessible.", null);
}
// link with OJAWA
try {
System.load(path);
logInfo("using relocated OJAWA from " + path);
}
catch(java.lang.UnsatisfiedLinkError e) {
logInfo("can not find relocated OJAWA at " + path + ": attempting from libraries of LD_LIBRARY_PATH.");
System.loadLibrary("ojawa");
}catch (Exception e)
{
logInfo("error catched: "+e.getMessage());
} |