This page contains an explanation of the Java INI Package, along with code examples and explanations. Although this document aims to be as concise as possible, developers are recommended to consult the javadoc for a more complete and upto date documentation of Java INI Package.
1. Before We Begin
1.1. Definitions for Java INI Package and this Tutorial
1.2. Package Overview
1.2.1. Interfaces
1.2.2. Concrete Classes
2. Steps needed to run in Java
2.1. Importing package in Java
2.2. Setting the Class Path
The Java INI Package and this website uses the following definitions:
.ini
IniFile
mono-space
font.For more information on the specifications of an INI file, click here.
The Java INI Package is made up of numerouse classes (both concrete and abstract). Here, we describe the essential parts of the package.
Since v1.0.0, the Java INI Package contains three important abstract classes which represent an INI File, its sections, and the section's items.
IniFile
IniFile
class defines the
operations to add or remove sections from the IniFile
, as well as other
operations for managing the ordering of the sections. This class is abstract as it
leaves the internal management of the sections to the concrete classes (such as the
BasicIniFile
and AdvancedIniFile
).IniSection
IniSection
class defines the methods to add or remove items from the section, as well as
other operations for managing the ordering of the items. Just like the IniFile
abstract class, this class is abstract as it leaves the internal management of the items
to the concrete classes (such as the BasicIniSection
and
AdvancedIniSection
).IniItem
IniItem
interface
defines the operations to set or get the value of the item.The reason for defining interfaces is simply to seperate the implementation from the API, and therefore allows different implementations for the interfaces.
Currently, the Java INI Package contains two implementations of the above interfafces, the Basic and Advanced concrete classes. The basic concrete classes are very small and simple implementation of the interfaces, and consistis of the following classes:
BasicIniFile
IniFile
interface.BasicIniSection
IniSection
interface.BasicIniItem
IniItem
interface.The Advanced concrete classes were introduced in version 0.2.00 and run quicker than the Basic concrete classes, but at the expence of more memory usage. Developers are recomended to use these classes over the Basic classes, unless memory usage is very critical. The following classes make up the Advanced concrete classes:
AdvancedIniFile
IniFile
interface.AdvancedIniSection
IniSection
interface.BasicIniItem
It is important to remember that we never refer to the concrete classes by their names,
but by their interfaces instead (similar to how you refer to a list object in Java as
java.util.List
rather than java.util.ArrayList
). We refer to
interfaces both in text and in java code and will only refere to a concrete class in
java code or, if we are explicitly discussing it, in text.
Before you can use the classes and interfaces that are in Java INI Package, you first need to tell Java where to look for the classes, which is done using the following import statement:
import
org.dtools.ini.*
;public class
MyFunnyIniClass
{Then write your java code as usual.
This section explains how to use a .jar
file (i.e. dTools's Java INI Package)
with your java code. For the more experienced developers, you can skip this part and go
straight to the next chapter, however, if you don't know how
to include a jar file with their code, please read this.
When you are readly to compile and run your java code (lets say you were compiling a class called MyExample.java), you must:
Type the following into the command line to compile your work:
Where ##.##.##
is the version number of the Java INI Package (e.g.
0.1.25
).
To run your compiled code, type the following into the command line:
Make sure you include the ;.
after the package name, as this tells
the java application to find the class MyExample in the current directory (and
not inside the jar file).
If you are developing your software on a Linux based OS instead of Microsoft Windows, replace the semi-colon (;) in the command line with a colon (:).