# jEdit 2.6 User's Guide

Next, Prev

## Chapter 11. Developing Plugins

# Plugin Properties

Plugins can use property files to store name/value pairs. Possible name/value pairs include human-readable strings, settings for the plugin, and so on. Certain properties can also contain information for use by jEdit.

When a plugin JAR is being loaded, all files with extension `.props` are read into jEdit's property list. Property files have a very simple syntax. Each line either starts with a hash ("#") in which case it is a comment and is ignored, or contains a name/value pair with an equals sign ("=") separating the name and value. Here is a simple example:

    # Property file for a non-existent 'FooPlugin'
    # Some properties with well-known names are queried by jEdit
    plugin.FooPlugin.name=Wonderful Foo Plugin
    plugin.FooPlugin.version=18.27beta9

    # Properties with arbitrary names can also be used by a plugin for
    # storing strings and user preferences
    foo.baz=Hello World
    qux=$

Various static methods in the `jEdit` class can be used to manipulate properties.

#### jEdit.getProperty() method

``public static String getProperty`(String name);`

``public static String getProperty`(String name, Object[] args);`

This method returns the value of the specified property. If the second form is used, elements of `args` array will be substituted every time a string of the form {`n`} occurs in the property value. For example, the below code will produce the output `Hello, World` if the value of the foo property is {0}, {1}:

    Object[] args = { "Hello", "World" };
    System.out.println(jEdit.getProperty("foo",args));

Under the hood, this form of `getProperty()` uses `java.text.MessageFormat` to do the formatting, and so supports many of MessageFormat's features. See the appropriate API documentation for details.

#### jEdit.getBooleanProperty() method

``public static boolean getBooleanProperty`(String name);`

This method returns the value of the named property as a boolean; if its value is "true", "on" or "yes" it will return `true`, otherwise it will return `false`.

#### jEdit.setProperty() method

``public static String setProperty`(String name, String value);`

This method sets the value of the specified property. Once a property is set with this method, it will be saved to the user properties file (the original property files in the JAR are never modified) and its value will be persistent for future sessions. To set properties which are not persistent, see the next method.

#### jEdit.setTemporaryProperty() method

``public static String setTemporaryProperty`(String name, String value);`

This method is similar to `setProperty()`, except that it sets the property in the default property list, which means it will not be saved to the user properties file. This can be used to set properties that are only to remain for the duration of the current editing session.

#### jEdit.setBooleanProperty() method

``public static void setBooleanProperty`(String name, boolean value);`

This method sets the value of the specified property to `true` if `value` is "true", and `false` if `value` is "false".

#### jEdit.unsetProperty() method

``public static String unsetProperty`(String name);`

This method removes the specified property. Subsequent calls to `getProperty()` will either return `null` or an empty string.

#### jEdit.resetProperty() method

``public static String resetProperty`(String name);`

This method resets the specified property to its default value.

Home, Up
Prev: The EditPlugin Class
Next: Plugin Documentation