Re: Access to LANG var from Java programs?
0> In article <[🔎] 200210070909.22652.egonw@sci.kun.nl>,
0> E. L. Willighagen <URL:mailto:egonw@sci.kun.nl> ("Egon") wrote:
Egon> working on internationalizing some OS Java tools, I was wondering
Egon> how to access bash export variables, one specific being LANG...
Egon>
Egon> The method System.getProperty() seems only to handle things like
Egon> "-Dlang=en_EN" as a command line option, and yes, the wrapper
Egon> could as such transfer the $LANG value to the Java program.
Egon>
Egon> But, is there no more direct way of accessing the $LANG var from
Egon> within the Java program itself?
Locale.getDefault() works for me:
$ LANG=en_GB java LocaleTest
en_GB
$ LANG=en_IE java LocaleTest
en_IE
Here's the code:
public final class LocaleTest {
public static void main(String[] args) {
System.out.println(java.util.Locale.getDefault().toString());
}
}
Reply to: