Re: how to get a bundle's root file path? [message #85506] |
Wed, 28 March 2007 08:58 |
Eclipse User |
|
|
|
Here is the most reliable method I found to make my app's root file path accessible to my java bundle code. In Windows, change bat file which runs the program to something like this
SET myapp.home=%cd%
ECHO set MyApp home to %myapp.home%
ECHO MyApp started
ECHO ----------------------------
@ECHO on
java -Dmyapp.home="%myapp.home%" -Dlog4j.debug -jar org.eclipse.osgi.jar -configuration osgi-config -consoleLog -debug -clean -dev -console
ECHO -----------------------------
ECHO MyApp stopped
@ECHO off
PAUSE
[Do corresponding change in Linux Shell script]
The key piece is to capture the directory of the run.bat file (usually it is located in the root of the OSGI app project folder) with this line
SET myapp.home=%cd%
e.g. this might have the value
C:\workspace\myapp
Then you pass this into the OSGi app with this
java -Dmyapp.home="%myapp.home%" ...
In your bundle Java code, you can access this value using
String myappHome = System.getProperty("myapp.home");
Best,
David
|
|
|
Powered by
FUDForum. Page generated in 0.07077 seconds