# io.github.libtmux.ServerEndpoint.fromEnvironment

- **Module:** io.github.libtmux
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-java/blob/5f88402151ff08fc0390dd438b90963692ec3fe4/libtmux/src/main/java/io/github/libtmux/ServerEndpoint.java#L53
- **Page:** https://libtmux.org/en/java/latest/reference/io-github-libtmux-serverendpoint-serverendpoint-fromenvironment/

```
static ServerEndpoint fromEnvironment(
        Map<String, String> environment)
```

The server an environment names, or tmux's own default when it names none.

{@code LIBTMUX_SOCKET_PATH} names a socket path and selects it with {@code -S};
{@code LIBTMUX_SOCKET} names a socket and selects it with {@code -L}. When both are set the
path wins, as it does in the Python libtmux and in tmux itself, which ignores {@code -L}
beside {@code -S}. A variable that is empty or blank counts as unset, each one on its own.
With neither set the result is {@link #defaultSocket()}.

{@code TMUX} is never read. tmux follows it by itself when no socket is selected, and
{@link TmuxEnvironment#config()} is the way to ask for that server by path.

## Parameters

- `environment` (`Map<String, String>`): the variables to read, typically {@code System.getenv()}

## Raises

- [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/IllegalArgumentException.html): if {@code LIBTMUX_SOCKET} holds a path separator; the message names the variable and leaves its value out
