.properties
≈ 5 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
.properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles. Each parameter is stored as a pair of strings, one storing the name of the parameter (called the key), and the other storing the value. Unlike many popular file formats, there is no RFC for .properties files and specification documents are not always clear, most likely due to the simplicity of the format.
.properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles. Each parameter is stored as a pair of strings, one storing the name of the parameter (called the key), and the other storing the value. Unlike many popular file formats, there is no RFC for .properties files and specification documents are not always clear, most likely due to the simplicity of the format. ==Format== Each line in a .properties file normally stores a single property. Several formats are possible for each line, including key=value , key = value , key:value , and key value . Single-quotes or double-quotes are considered part of the string. Trailing space is significant and presumed to be trimmed as required by the consumer. Comment lines in .properties files are denoted by the number sign (#) or the exclamation mark (!) as the first non blank character, in which all remaining text on that line is ignored. The backwards slash is used to escape a character. An example of a properties file is provided below. You are reading a comment in ".properties" file. ! The exclamation mark ('!') can also be used for comments. Comments are ignored. Blank lines are also ignored. Lines with "properties" contain a key and a value separated by a delimiting character. There are 3 delimiting characters: equal ('='), colon (':') and whitespace (' ', '\t' and '\f'). website = https://en.wikipedia.org/ language : English topic .properties files A word on a line will just create a key with no value. empty Whitespace that appears between the key, the delimiter and the value is ignored. This means that the following are equivalent (other than for readability). hello=hello hello = hello To start the value with whitespace, escape it with a backslash ('\'). whitespaceStart = \ In the example above: the number sign (#) and the exclamation mark (!) at the beginning of a line (line 1, 2, etc), marks text as comments and comments they are ignored, an empty line (line 5) is also ignored, " " (line 8) would be a key, and its corresponding value would be " ", all of the whitespace at the beginning of line 44 is excluded. This means that the key " " (line 43) has the value " " and not " !". Before Java 9, the encoding of a .properties file is ISO-8859-1, also known as Latin-1. All non-ASCII characters must be entered by using Unicode escape characters, e.g. \uHHHH where HHHH is a hexadecimal index of the character in the Unicode character set. This allows for using .properties files as resource bundles for localization. A non-Latin-1 text file can be converted to a correct .properties file by using the native2ascii tool that is shipped with the JDK or by using a tool, such as po2prop, that manages the transformation from a bilingual localization format into .properties escaping. An alternative to using unicode escape characters for non-Latin-1 character in ISO 8859-1 character encoded Java *.properties files is to use the JDK's XML Properties file format which by default is UTF-8 encoded, introduced starting with Java 1.5. Another alternative is to create custom control that provides custom encoding. In Java 9 and newer, the default encoding specifically for property resource bundles is UTF-8, and if an invalid UTF-8 byte sequence is encountered it falls back to ISO-8859-1. ==Editing== Editing .properties files is done using any text editor such as those typically installed on various Operating Systems including Notepad on Windows or Emacs, Vim, etc. on Linux systems. Third-party tools are also available with additional functionality specific to editing .properties files such as: Data Validation Creating new keys Synchronization of key names Automatic bi-directional conversion of non-ASCII symbols to support non-Latin languages Integration with Eclipse ==See also== XML, JSON and YAML are used by some for more complex configuration formats. ==References== ==External links== - gives the precise semantics of well-formed Java property files - describes property resource bundles - explains Java properties in a simple XML format. MultiProperties - It is an Eclipse plugin for editing multiple key-value based files with similar content. This kind of file format can be Properties for example in Java programming language, which is frequently used for backing a ResourceBundle. Bracket Properties - a refresh of the Properties concept while keeping the ubiquitous .properties file format intact. Java Properties Editor (Application + Eclipse plugin) - useful utility to view and to edit properties files in a whole project. DOKSoft Properties Editor Eclipse plugin - i18n tool for installing into Eclipse IDE. Message Editor - it manages i18n for Java application. It generates XML property files. It includes two stylesheets for .properties and .xml property generation at compile time (Ant based.) JLokalize - open source Java properties editor with reversal function and spell check Config::Properties - Perl CPAN. Jackson Properties module is a library that allows mapping Properties file contents into Java Objects and back, similar to how XML and JSON is commonly mapped SAPUI5 - Use of Localized Texts in Applications
Text derived from https://en.wikipedia.org/w/index.php?oldid=1369050493 under CC BY-SA 4.0; modifications have been made.