Click here to Skip to main content
15,881,082 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Related to java console app,
Below print statement prints special characters, if i run java application from eclipse
System.out.println("hello..测试,收到不用理会")

If, i execute the console app(.jar) from windows command line, I see junk
like below
hello..?????????

Any solution?

What I have tried:

public class App {
	
	public static void main(String[] args)
			throws JsonGenerationException, JsonMappingException, IOException, AtlasException {
		System.out.println("hello.."+"测试,收到不用理会");
}
Posted
Updated 13-Feb-20 5:39am

This SO post may help you:
How to print chinese characters to the windows console correctly?[^]
Technically, there is nothing you can do from code; this is just a matter of Windows Console's configuration.
 
Share this answer
 
Comments
Prashanthi Kakarla 13-Feb-20 11:03am    
My requirement is to store the message(doesn't matter chinese or any other characters) to a file
<prev>
String test = "hello.."+"测试,收到不用理会";
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
mapper.writeValue(new File("C:\\testpayload\\transformed.json"), test);

Is it possible to set encoding to com.fasterxml.jackson.databind.ObjectMapper.writeValue()?
phil.o 13-Feb-20 11:09am    
This SO post delas with that:
Jackson ObjectMapper with UTF-8 encoding?[^]
If UTF-8 doesn't fit, UTF-16 should.
 
Share this answer
 
Comments
phil.o 13-Feb-20 15:11pm    
Useful link :)
:thumbsup:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900