My problem is best explained in an example:
The following program is run on a Linux system that is not in Unicode mode yet, but in ISO-8859-15. The environment is set as follows: LC_CTYPE=de_DE@euro
import java.io.*;
import java.util.*;
public class UnicodeTest {
public static void main(String[] args) throws Exception {
Runtime.getRuntime().exec(new String[] { "foobar", "äöü" });
}
}
When I compile this program in the command line using javac
and run it, foobar
gets the argument äöü
correctly, in ISO-8859-1. The same program, run from Netbeans, passes the argument as Unicode, thus making it unusable in the called program. The same happens in Tomcat when that method is called. Which setting or environment variable uses Java to determine how to pass arguments in Runtime.exec()
?
Found it. The behaviour is controlled by the system property file.encoding
. Netbeans sets it to UTF-8. In the command line, it's ISO-8859-15
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With