How to read a file from the JBuilder installation directory when creating an OpenTool

So, you're creating a JBuilder OpenTool (using the JBuilder OpenTool API) and you want to use a properties file to configure your OpenTool. Knowing the way OpenTools are installed within the JBuilder environment, you come to the conclusion that the best place to store that properties file is in the "/lib/ext" directory under the JBuilder installation directory. That being said, how do you access that directory from within your OpenTool?

Fortunately this is pretty easy ... once you know how to do it. :) Here is a simple one line example showing how to create a File object that refers to a configuration file named that is located in the "/lib/ext" directory:

File propertiesFile = new File(PropertyManager.getInstallRootUrl().getFile() +  "/lib/ext/");

As you can see from the example, not only can you access the "/lib/ext" subdirectory, you can also access other JBuilder subdirectores, if you need to. However, in my case, when I'm developing OpenTools, I prefer to put my configuration files in this directory, because it makes the installation process much easier for the end user.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.