Constants are global variables that contain system information -- such as os or screen dimensions -- that is sometimes advantageous to know at run time.
The file separator that a system uses. On Windows this will be
\ and on Linux and Mac it will be /.
Type: String
Example:
print("This system uses '" + FILE_SEP + "' as a file separator.");
Output:
This system uses '/' as a file separator.
The height of the screen measured in pixels. Note that with multiple screens this may only apply to the main monitor.
Type: int
Example:
print("This screen is " + SCREEN_HEIGHT + "px tall.");
Output:
This screen is 768px tall.
The width of the screen measured in pixels. Note that with multiple screens this may only apply to the main monitor.
Type: int
Example:
print("This screen is " + SCREEN_WIDTH + "px wide.");
Output:
This screen is 1366px wide.
The operating system in use.
Type: String
Example:
print("Running OS: " + SYSTEM_OS);
Output:
Running OS: Linux
The path to the user's home directory.
Type: String
Example:
print("User's home directory: " + USER_HOME_DIR);
Output:
User's home directory: /home/john
Note that on *nix systems running this as root, even when logged in as a different user, will yield a different result.
If you run your program with sudo the output will
look like this:
User's home directory: /root
The path to the temporary directory on the system.
Type: String
Example:
print("Temp directory: " + TEMP_DIR);
Output:
Temp directory: /tmp
The current user's user name.
Type: String
Example:
print("User name: " + USER_NAME);
Output:
User name: john
Note that on *nix systems running this as root, even when logged in as a different user, will yield a different result.
If you run your program with sudo the output will
look like this:
User name: root
The directory the program is being run from.
Type: String
Example:
print("This is being run from " + WORKING_DIR);
Output:
This is being run from /home/john/javauto/