I've done a basic guessing game with Java. It's in Spanish so it has some accent marks (á,é) and some inverted exclamations marks (¡). The problem is that when I run the program on the Command Line it doesn't show the accents and it looks weird to read... Can someone help me with this?
-
I don't have a complete answer, but the info in this post might help: http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using – Barend Aug 25 '13 at 18:23
2 Answers
The command line simply cannot show some characters only by printing them over System.out . Maybe it would be easier to write your output in a simple JTextField or JLabel or something like that, for JTextField/JLabel is able to show every unicode characters which are included in the current Font.

- 29
- 1
- 7
-
Hi! Using JTextField or JLabel would require a graphical interface? I'm learning Java so I don't know a lot, but I could research it. If not, could you help me? Thank you! – José María Aug 27 '13 at 10:06
I know this is an old question, but this may answer it, in case someone faces the same problem in the future.
When you run the program from command prompt, you need to pass an option to the JVM: -Dfile.encoding=utf-8
Your command would look like this :
java -Dfile.encoding=utf-8 <mainClass> <... other args>
In case you can't add this option manually, you can tell Windows to pick it up automatically from the environment variable JAVA_TOOL_OPTIONS :
- Win + R
- Open: sysdm.cpl
- Advanced
- Environment Variables
- User variables ; New...
- Variable name: JAVA_TOOLS_OPTIONS
- Variable value: -Dfile.encoding=UTF-8
- OK
- OK
Now, if you type:
java <MainClass> <... other args>
Windows will add the encoding option by itself.

- 148
- 6