This question has already been answered:

The code in java gets the text from the file, and compares it with other text. When running in eclipse everything works, and if the texts are the same, a message is displayed. After exporting to a jar file, the application does not work correctly in the windows console. Encoding of projects and files - UTF-8 .

Reported as a duplicate by members of Pavel Mayorov , pavel , tutankhamun , Denis , HamSter Sep 30 '16 at 9:03 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • [everything is written here] [1] ps learn how to use Google. They say it helps. [1]: stackoverflow.com/questions/10143998/… - huffman
  • There is nothing about comparing 2 lines. - hjacob30
  • you can compare two strings so String s1 = "String"; if (s1.equals ("String")) {System.out.println ("ok"); } - huffman
  • I am aware of how the lines are compared. When run in eclipse, they are compared and equal, in the windows console everything is different. - hjacob30
  • one
    with encodings here: skipy.ru/technics/encodings.html well and a lot of other useful things;) - stackoverflow

1 answer 1

This problem occurs due to the fact that the default encoding of Windows is windows-1251, and the Windows console uses the Cp866 encoding. We start the console, click on the window title and select properties. In the properties on the Font tab, we put the font Lucida Console and click OK. Next, we type in the ChCp 1251 console, in response we get the Current code page: 1251. Now we launch the Java program and make sure that everything works.