Is there a command line parameter similar to
java.exe --locale=EN_US -jar mylib.jar .....
Gianni
Try this:
java -Duser.language=en -Duser.region=US -jar mylib.jar
Patrick
That depends on the target program's sensitivity to locales and how it reads
them from the command line. I find nothing in a short googling that indicates
a universal mechanism. I suppose you could use Windows' Control Panel to
change the default locale before running the program. I do not know if
there's a way to script such a change.
> Is there a command line parameter similar to
>
> java.exe --locale=EN_US -jar mylib.jar .....
java ...
There is no such command-line parameter, but you can change environment
variable values with the "-D" option if the program uses them.
Changing the locale in the environment is unlikely to have any effect on the
particular Java program unless the program itself has internationalization
support, e.g., via ResourceBundle. If it does, then such a program might
support a "-D" or positional parameter that sets the locale.
<http://download.oracle.com/javase/tutorial/i18n/index.html>
--
Lew
Ceci n'est pas une pipe.
Patrick wrote:
> Try this:
>
> java -Duser.language=en -Duser.region=US -jar mylib.jar
Huh, those properties aren't listed at
<http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()>
Are they universally available? (Which is not to say that every Java program
refers to them.)
Documentation?
I see "user.language" referenced from:
http://download.oracle.com/javase/6/docs/api/java/util/Locale.html#setDefault%28java.util.Locale%29
And then I read
<http://java.sun.com/developer/technicalArticles/J2SE/locale/>:
> ... on some Java runtime implementations, the application user can
> override the host's default locale by providing this information on
> the command line by setting the user.language, user.country, and
> user.variant system properties.
> (...)
> You can experiment with the above code example. Running on a U.S.
> English system, the above code prints en_US. If you provide
> command-line options as described above, you can coax your
> application into using any locale you need. For example, you can
> invoke the application like this:
>
> java -Duser.language=fr -Duser.country=CA Default
This gives pretty good chance the properties are supported by most
(if not all) available JVM implementations. If one has control over
the JVM implementation used, I think the given documentation is
enough in order to rely on the properties for start-up configuration.
Here's some more docs from IBM:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzaha/sysprop2.htm
This lists the "file.encoding" property which is also not listed at
System.getProperties() but in my experience is widely used and
relied on as standard.
--
Stanimir
Call Locale.setDefault as the first thing in the code.
And remember if it is not your code then you can
create a main that calls the real main after doing so.
Arne
Try something like :
java -Duser.language=en -Duser.region=US MyApplication
Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript or PowerBuilder snippets
* http://rgagnon.com/howto.html
* http://rgagnon.com/bigindex.html
see http://mindprod.com/jgloss/properties.html
user.county, user.region and user.language
--
Roedy Green Canadian Mind Products
http://mindprod.com
Doubling the size of a team will probably make it produce even more slowly.
The problem is the more team members, the more secrets, the less each team
member understands about how it all fits together and how his changes may
adversely affect others.
if you look at http://java.sun.com/developer/technicalArticles/J2SE/locale/
Half way down it mentions the command line arguments ( user.language
and user.country ).