uk.ac.starlink.util
Class Loader

java.lang.Object
  |
  +--uk.ac.starlink.util.Loader

public class Loader
extends Object

Provides utilities associated with loading resources.


Field Summary
static String PROPERTIES_FILE
          Name of the file in the user's home directory from which properties are loaded.
 
Constructor Summary
Loader()
           
 
Method Summary
static File getPropertiesFile()
          Returns the name of the file from which properties will be loaded by this class.
static void loadLibrary(String libname)
          Loads a native library given its name.
static void loadProperties()
          Ensures that the user's customised properties have been loaded; these are read once from the file returned by the getPropertiesFile() method and incorporated into the System properties.
static File starjavaDirectory()
          Returns the location of the main Starlink java directory which contains the lib, bin, etc, source directories and others.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_FILE

public static final String PROPERTIES_FILE
Name of the file in the user's home directory from which properties are loaded.

See Also:
Constant Field Values
Constructor Detail

Loader

public Loader()
Method Detail

starjavaDirectory

public static File starjavaDirectory()
Returns the location of the main Starlink java directory which contains the lib, bin, etc, source directories and others. It gets this by working out what jar file this class has been loaded from - there may be circumstances under which this doesn't work? but it's a best guess.

If for some reason the directory cannot be located, null is returned.

Returns:
the top level starlink java directory, or null if it can't be found

loadLibrary

public static void loadLibrary(String libname)
                        throws SecurityException,
                               UnsatisfiedLinkError
Loads a native library given its name. If it is not found on java.library.path, the architecture-specific lib directory in the installed Starlink system is searched.

Parameters:
libname - the name of the library (not including system-specifics such as 'lib' or '.so')
Throws:
SecurityException - if a security manager exists and its checkLink method doesn't allow loading of the specified dynamic library
UnsatisfiedLinkError - if the library does not exist
See Also:
System.loadLibrary(java.lang.String)

getPropertiesFile

public static File getPropertiesFile()
Returns the name of the file from which properties will be loaded by this class.

Returns:
a file called PROPERTIES_FILE in the directory given by the System property "user.home".

loadProperties

public static void loadProperties()
Ensures that the user's customised properties have been loaded; these are read once from the file returned by the getPropertiesFile() method and incorporated into the System properties. Calling this method after the first time has no effect.

See Also:
System.getProperties()

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.