You are not logged in.
Hey there!
I've got an issue conceirning my urxvt-terminal (although other terminals act the same).
I am into learning Java und therefore use the said terminal and vim.
At the beginning everything works fine, I can compile my program using periods as the floating point seperator in the *.java file / sourcecode.
But then, when I want a user input a double, the program wants me to use a comma and crashes otherwise.
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at Test.main(Test.java:6)Anyway, the output of my Java programs uses the period as well.
After some investigation I thought to have found the problem and tried to change the LC_NUMERIC and LC_MONETARY variables to "C" / "POSIX". But it doesnt work.
I know there's the possibility to change the locale inside my Java sourcecode; but since I am into programming and stuff, I want it to use the period all the time for the consistency.
That's what locale puts out
$ locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC=C
LC_TIME="de_DE.UTF-8"
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=And also
$ locale -a
C
POSIX
de_DE
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
de_DE@euro
deutsch
germanThank you in advance and best regards!
Offline
Java has no notion of POSIX-style locale. Some JVMs, including both Oracle’s and OpenJDK’s, base their default locale on LC_ALL if not specified explicitly, but that’s all. Other LC_* variables are not taken into account, and could not be taken, since Java locale framework works in a different way than POSIX’s.
If you want to use a locale with dots as a decimal separator, you have to use one as a whole: for example en_US. You can’t just get a part of one locale, a part of another and mix them together.
Of course you could also define your own locale, which works like de_DE but has dots as a decimal separator: via VM extensions, SPIs and LocaleServiceProviders. But I truly doubt it’s worth the hassle.
Offline
Not an Installation issue, moving to Apps and DEs...
Offline