i have simple console program in java, i try to get input from user the input is in Hebrew "שלום" but when i tried to read it i get ???? , but i wish to get "שלום" , how is the best way?
my code:
public static void main(String[] args) {
String s;
Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println(s);
}
}
output:
run:
Enter a string
שלום
????
BUILD SUCCESSFUL (total time: 5 seconds)
i know that i should use utf-8 but i really dont know how... any help?
If you are using windows you need to check the terminal encoding.
To do this just type chcp in the console
as output you should see chcp 28598
if you see diffrent number type chcp 28598
Now your console encoding is set to hebrew.