last update: 08/02/2004 23:58:13

The goals


The reason for creating this project is that we want to give all Java developers the ability to use configuration files that are based on XML. It is more and more common to use XML rather than the old properties file. One of the main aspect for us is to write a simple and small software. This package contains only 2 class whereas one of these class is our own Exception.

Of course we could go crazy about this and define a real configuration framework. But it is not our intention to show everybody that we can write sophisticated Java application. It should be simple to use and of course also simple to understand.
You can also take this as a short introduction to XML and how it can be used in a Java application. jConfig is based on JAXP.

jConfig supports a 2 level hierarchical structure. Therefore you can group certain properties into categories. There is one default category called "general". Let me show you an example how such a config.xml (or whatever you name it) might look like:
<properties>
  <category name="JDBC">
    <property name="URL" value="jdbc:mysql://localhost/iportal" />
    <property name="USER" value="dice" />
    <property name="PWD" value="dice" />
    <property name="DRIVER" value="org.gjt.mm.mysql.Driver" />
  </category>
  <category name="general">
    <property name="debug_file" value="/tmp/mystuff.log" />
    <property name="servlet_context" value="/MyStuff" />
    <property name="image_path" value="/MyStuff/img" />
    <property name="site_map_root" value="application" />
    <property name="upload_dir" value="/tmp/iPortal_upload" />
  </category>
</properties>

This XML structure is the default one. But it is also possible to nest categories and to have categories inside categories. Herer is an example of such an XML structure:

<properties>
  <category name="general">
    <maxUsers>100</maxUsers>
  </category>
  <category name="servers">
    <category name="news">
      <host>news.mydomain.com</host>
      <port>1244</port>
    </category>
    <category name="email">
      <host>mymail.com</host>
      <port>9211</port>
    </category>
  </category>
</properties>

jConfig has envolved a lot since its first version. Take a look at the getting started or the advanced documentation to find out more.