Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Netbeans Chinese characters in java project properties run arguments

I am writing a Netbeans java program to handle Chinese characters in arguments. I am able to use unicode codes and Chinese characters in my coding and they compiles and display on console correctly. However, when I pass the Chinese characters via project properties run arguments, they all turn into ?????. I have already set my project encoding to UTF-8 and VM options -Dfile.encoding=UTF-8. Here is my coding, please help.

public static void main(String[] args) {
    String test = "\u5973\u58eb";
    System.out.println(test);      //works
    String test2 = "女士2";
    System.out.println(test2);     //works
    System.out.println(args[0]);   //copy&paste test2 to argument, not works, showing ??
}

NB: I use jdk 1.8.0_202, Ant v1.10.4, Windows 10, Netbeans 10, fonts used for Netbeans output and termianl are monospaced14, project is created using Netbeans "java application". Problem occurs when run within Netbeans or on Windows command prompt chcp 65001 both with -Dfile.encoding=UTF-8.

NB: With skomisa's advise, I further test with Windows "use unicode utf8 for worldwide language support" checked. I also move away from Netbeans but use the jar to run on Windows cmd with chcp 65001.

D:\.......>java -cp dist/myjar.jar -Dfile.encoding=UTF8 java.mypackage.TestUTF8 女士
女士
女士2
女士

D:\.......>java -cp dist/myjar.jar java.mypackage.TestUTF8 女士
??
??2
女士

So with -Dfile.encoding=UTF8 (first run), constant string in coding works while arguments not. Without -Dfile.encoding (second run), in-code constants not work while arguments works. But I need both. I have Chinese constant string in my program as well as in program arguments. Can somebody tell me what can be done please.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!