github.com/mattyr/nomad@v0.3.3-0.20160919021406-3485a065154a/website/source/docs/drivers/java.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Drivers: Java" 4 sidebar_current: "docs-drivers-java" 5 description: |- 6 The Java task driver is used to run Jars using the JVM. 7 --- 8 9 # Java Driver 10 11 Name: `java` 12 13 The `Java` driver is used to execute Java applications packaged into a Java Jar 14 file. The driver requires the Jar file to be accessible from the Nomad 15 client via the [`artifact` downloader](/docs/jobspec/index.html#artifact_doc). 16 17 ## Task Configuration 18 19 The `java` driver supports the following configuration in the job spec: 20 21 * `jar_path` - The path to the downloaded Jar. In most cases this will just be 22 the name of the Jar. However, if the supplied artifact is an archive that 23 contains the Jar in a subfolder, the path will need to be the relative path 24 (`subdir/from_archive/my.jar`). 25 26 * `args` - (Optional) A list of arguments to the optional `command`. 27 References to environment variables or any [interpretable Nomad 28 variables](/docs/jobspec/interpreted.html) will be interpreted 29 before launching the task. For example: 30 31 ``` 32 args = ["${nomad.datacenter}", "${MY_ENV}", "${meta.foo}"] 33 ``` 34 35 * `jvm_options` - (Optional) A list of JVM options to be passed while invoking 36 java. These options are passed without being validated in any way by Nomad. 37 38 ## Examples 39 40 A simple config block to run a Java Jar: 41 42 ``` 43 task "web" { 44 driver = "java" 45 46 config { 47 jar_path = "local/hello.jar" 48 jvm_options = ["-Xmx2048m", "-Xms256m"] 49 } 50 51 # Specifying an artifact is required with the "java" 52 # driver. This is the # mechanism to ship the Jar to be run. 53 artifact { 54 source = "https://dl.dropboxusercontent.com/u/1234/hello.jar" 55 56 options { 57 checksum = "md5:123445555555555" 58 } 59 } 60 ``` 61 62 ## Client Requirements 63 64 The `java` driver requires Java to be installed and in your system's `$PATH`. On 65 Linux, Nomad must run as root since it will use `chroot` and `cgroups` which 66 require root privileges. The task must also specify at least one artifact to 67 download, as this is the only way to retrieve the Jar being run. 68 69 ## Client Attributes 70 71 The `java` driver will set the following client attributes: 72 73 * `driver.java` - Set to `1` if Java is found on the host node. Nomad determines 74 this by executing `java -version` on the host and parsing the output 75 * `driver.java.version` - Version of Java, ex: `1.6.0_65` 76 * `driver.java.runtime` - Runtime version, ex: `Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)` 77 * `driver.java.vm` - Virtual Machine information, ex: `Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)` 78 79 ## Resource Isolation 80 81 The resource isolation provided varies by the operating system of 82 the client and the configuration. 83 84 On Linux, Nomad will attempt to use cgroups, namespaces, and chroot 85 to isolate the resources of a process. If the Nomad agent is not 86 running as root, many of these mechanisms cannot be used. 87 88 As a baseline, the Java jars will be run inside a Java Virtual Machine, 89 providing a minimum amount of isolation. 90