How do I pass VM Unicode arguments using eclipse?
I cannot read the unicode lines passed as VM arguments if I start the process from the Eclipse IDE.
For example:
ArrayList<String> commands = new ArrayList<>();
commands.add("java");
commands.add("-classpath");
commands.add("bin");
commands.add("-Dprop=ÁÉÍÓÚ");
commands.add("test.ReadProp");
ProcessBuilder pb = new ProcessBuilder(commands);
Process process = pb.start();
BufferedReader in;
String line;
in = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = in.readLine()) != null)
System.out.println(line);
With dough .ReadProp
String prop = System.getProperty("prop");
System.out.println("prop: " + prop);
Result
prop: ??????????
The only solution seems to be forcing the environment variable LANG
this way
pb.environment().put("LANG", "it_IT.UTF-8");
Are there any better solutions? More portable?
Updated at 20:30
Another solution seems to add an environment LANG=it_IT.UTF-8
to the BASH script that starts the Eclipse process. But this is not something I can control on every computer.
+3
source to share