---
title: "Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8"
author: "J2EE大鸟"
date: "2013-01-22T22:24:48Z"
tags: []
categories: ["编程语言"]
slug: "picked-up-java-tool-options-dfile-encoding-utf8"
draft: false
lastmod: "2013-01-22T22:24:48Z"
id: 1774040
url: "https://benworld.iteye.com/blog/1774040"
---

From the [JVM™ Tool Interface](http://java.sun.com/javase/6/docs/platform/jvmti/jvmti.html#tooloptions) documentation…

> Since the command-line cannot always be accessed or modified, for example in embedded VMs or simply VMs launched deep within scripts, a `JAVA_TOOL_OPTIONS` variable is provided so that agents may be launched in these cases.

By setting the (Windows) environment variable `JAVA_TOOL_OPTIONS` to `-Dfile.encoding=UTF8`, the (Java) `System` property will be set automatically every time a JVM is started. You will know that the parameter has been picked up because the following message will be posted to `System.err`:

> `Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8`