Skip to main content



      Home
Home » Eclipse Projects » Equinox » Re: how to get a bundle's root file path?
Re: how to get a bundle's root file path? [message #85506] Wed, 28 March 2007 08:58
Eclipse UserFriend
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
Previous Topic:Monitoring Incubator Bundles and JMX Access Restrictions
Next Topic:Class loader listener
Goto Forum:
  


Current Time: Wed Apr 30 16:11:27 EDT 2025

Powered by FUDForum. Page generated in 0.07077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top