Env

Env object is used for access of the environment variables.

Version 3.x

Basic Usage

1
2
3
4
5
6
7
8
var env = require('core/v3/env');
var response = require('http/v3/response');

var os = env.get("os.name");
response.println("[OS]: " + os);

response.flush();
response.close();

Definition

Functions


Function Description Returns
get(key) Returns the value per key from the environments variables string
list() Returns the list of the environments variables in JSON formatted string string

Compatibility

Rhino Nashorn V8
โœ… โœ… โœ…


Version 2.x

Basic Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* globals $ */
/* eslint-env node, dirigible */

var env = require('core/env');
var response = require('net/http/response');

var os = env.get("os.name");
response.println("[OS]: " + os);
response.println("[OS Name]: " + env.getOperatingSystemName());
response.println("[OS Arch]: " + env.getOperatingSystemArchitecture());
response.println("[OS Version]: " + env.getOperatingSystemVersion());
response.println("[File Separator]: " + env.getFileSeparator());
response.println("[Path Seprator]: " + env.getPathSeparator());
response.println("[Line Seprator]: " + env.getLineSeparator());
response.println("[User Dir]: " + env.getUserDirectory());
response.println("[User Home]: " + env.getUserHome());
response.println("[User Name]: " + env.getUserName());

response.println("[All]: " + env.getAll());

response.flush();
response.close();

Definition

Functions


Function Description Returns
get(key) Returns the value per key from the environments variables string
set(key, value) Sets the value per key to the environment variables -
getAll(key) Returns the value per key form the environments variables array of key/value pairs
getOperatingSystemName() Returns the โ€˜os.nameโ€™ value from the environments variables string
getOperatingSystemArchitecture() Returns the โ€˜os.archโ€™ value from the environments variables string
getOperatingSystemVersion() Returns the โ€˜os.versionโ€™ value from the environments variables string
getFileSeparator() Returns the โ€˜file.separatorโ€™ value from the environments variables string
getPathSeparator() Returns the โ€˜path.separatorโ€™ value from the environments variables string
getLineSeparator() Returns the โ€˜line.separatorโ€™ value from the environments variables string
getUserDirectory() Returns the โ€˜user.dirโ€™ value from the environments variables string
getUserHome() Returns the โ€˜user.homeโ€™ value from the environments variables string
getUserName() Returns the โ€˜user.nameโ€™ value from the environments variables string

Compatibility

Rhino Nashorn V8
โœ… โœ… โŒ
Edit