user7250516
user7250516

Reputation:

JavaFx Greek Character Encoding

I recently created an application in eclipse. I exported it as a runnable jar and with english all are working fine except greek letters. When i try to import a file with greek characters inside my application, they dont show properly. I tried changing all encoding to UTF-8 but no luck. I also have the exact application with greek menu and it doesnt show that correctly either. Only way to fix it so far is to create a runnable .bat file and paste this inside:

start cmd /k java -Dfile.encoding=UTF-8 -jar Compiler.jar

But this doesnt make any sense to me, because every file and folder inside my project are using the UTF-8 encoding. I am using windows 10, latest eclipse and javafx for eclipse.

The greek letters exist in some files inside the project, for example src/grammars/xx-file. The application finds them and reads them without problem. Greek letters also show on Labels and titles of the applications. I use the default fonts of the javafx environment. For example, one file contain this: I->#E|ε. When imported to the program it changes to this: I->#E|Ξµ

I also wanna add that in order to read those files from within the .jar i had to use InputStream. So it it possible to specify encoding to InputStream?

Upvotes: 1

Views: 1080

Answers (1)

user7250516
user7250516

Reputation:

Okay for anyone insterested. I found the solution to the problem. I added an

InputStreamReader inputReader = new InputStreamReader(streamIn, StandardCharsets.UTF_8);

to every file that my application try to read, and by doing that it fixed the problem. So i guess the executable .jar file is not using by default the UTF-8 encoding and we have to specify it on the reading phase.

Upvotes: 1

Related Questions