.. java:import:: java.io File .. java:import:: java.io IOException .. java:import:: java.nio.file Files .. java:import:: java.util HashMap .. java:import:: java.util Map Environment =========== .. java:package:: com.ampl :noindex: .. java:type:: public class Environment This class provides access to the environment variables and provides facilities to specify where to load the underlying AMPL interpreter. Fields ------ DefaultAMPLPaths ^^^^^^^^^^^^^^^^ .. java:field:: String[] DefaultAMPLPaths :outertype: Environment PATH ^^^^ .. java:field:: public static final String PATH :outertype: Environment Get the platform dependent name of the \ ``path``\ environment variable. To append a directory to current list of system paths, follow the snippet below: .. parsed-literal:: Environment e = new Environment(); String paths = e.getMap().get(Environment.PATH); e.getMap().put(Environment.PATH, paths + java.io.File.pathSeparatorChar + "/mynewpath"); Note that changing the paths in this way has effect only until the underlying AMPL process is started (in the :java:ref:`AMPL` constructor). map ^^^ .. java:field:: Map map :outertype: Environment Constructors ------------ Environment ^^^^^^^^^^^ .. java:constructor:: public Environment() :outertype: Environment Default constructor, just copies the values of the current system environment variables. Expects the AMPL binary in a directory included in the system paths list or in the default position (which is APIJARLOCATION/ampl) Environment ^^^^^^^^^^^ .. java:constructor:: public Environment(String binDir) :outertype: Environment Permits the user to specify a custom location for the AMPL executable. :param binDir: Directory to search the AMPL executable in Methods ------- addToPath ^^^^^^^^^ .. java:method:: @Deprecated public void addToPath(String directory) :outertype: Environment Add the specified directory to the system path (for AMPL interpreter subprocess environment) Note that it has no effect after the AMPL interpreter is constructed. :param directory: Directory to be appended findAmplPath ^^^^^^^^^^^^ .. java:method:: String findAmplPath() :outertype: Environment Find AMPL Path: Try building API path/AMPL Otherwise default to system paths (binDir = empty) :param path: Bin directory :throws AMPLExpection: if AMPL executable is not found :return: Null if not found, path of the ampl executable otherwise findExecutableInPathLocation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: String findExecutableInPathLocation(String exeName) :outertype: Environment findPathEnvironmentVariableName ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. java:method:: String findPathEnvironmentVariableName() :outertype: Environment getBinDir ^^^^^^^^^ .. java:method:: public String getBinDir() :outertype: Environment Returns the directory containing the overriding AMPL executable directory. getMap ^^^^^^ .. java:method:: public Map getMap() :outertype: Environment Get the inner map of environment variables getWorkingDir ^^^^^^^^^^^^^ .. java:method:: String getWorkingDir() :outertype: Environment Returns the path to the current working directory. setBinDir ^^^^^^^^^ .. java:method:: public void setBinDir(String exePath) :outertype: Environment Sets the directory in which the AMPL executable is located. Does not perform any check regarding whether the AMPL executable in there is working or not. :param exePath: Path to the AMPL executable (without file name) toString ^^^^^^^^ .. java:method:: public String toString() :outertype: Environment