Troubleshooting Java "Error: encoding GBK non-mapped characters"

Source: Internet
Author: User

Reprint: http://blog.csdn.net/l1028386804/article/details/46583279

In the CMD console compile times Error: encoding GBK non-mapped characters

Check:

1, check the local locale language setting Chinese no problem

2. This program can run normally on eclipse

Right-click Properties-resource-text file encoding is UTF-8

Workaround:

1. Operation is using javac-encoding UTF-8 Demo.java

===> compile and run the code through

2. Notepad open Java source file, save as Select ANSI encoding

===> also compiles and runs code through

Description

ANSI: American National Standards Association, the system preset standard text storage format. Simplified Chinese coding GB2312, which is actually a code page for ANSI 936

UTF-8: Universal Character Set conversion format, which is an encoding designed for transmission, 2 binary, encoding Unicode in 8-bit units, and selecting the UTF-8 format if you are using legacy transport media that can only support 8 bits of important data within a homogeneous bit group.

In UTF-8, the English characters are still the same as ASCII encoding, so the original library can continue to be used. The encoding range for Chinese is between 0080-07ff, so it is 2 bytes (but the two bytes and GB encoded two bytes are different), and the UTF encoding can be processed with a specialized Unicode processing class.

Code:

1  Public classhelloworldwww{2           Public Static voidMain (String args[]) {3                 intNum;//declares an integer variable num4num = 3;//assigning an integer variable to a value of 35                //output string, where the "+" sign is used to connect the variable6System.out.println ("This is the number" +num);7System.out.println ("I have the +num+" book!) ");8          }9  Ten}
View Code

1 /*2 # @Time: 2018-8-3 19:163 # @Author: XXX4 # @Mail: [email protected]5 # @Function: Java uses a For loop to traverse the print array and time delay to implement the countdown6 */7 8 ImportJava.util.concurrent.TimeUnit;9 Ten  Public classDemo { One      Public Static voidMain (string[] args)throwsException { A          for(inti = 10; I >= 0; i--) { -TimeUnit.SECONDS.sleep (1); - System.out.println (i); the         } -     } - } -  + /* - Java uses javac compile times error: unreported exception java.net.MalformedURLException; it must be snapped or declared to throw + andymacbookpro:push andy$ javac Push.java A Push.java:7: Unreported exception java.net.MalformedURLException; must be snapped or declared to throw at url = new URL (urlstr); -              ^ - 1 Error - you need to include the following statement in your code: - throws Exception -  in or add the Try{}catch () {} block to the code. -  to Reference: + Javac compile times Error in Java: Unreported exception java.net.MalformedURLException; must be snapped or declared to throw-csdn blog38701907 -  the */
Java code with Chinese characters or Mandarin notes

Troubleshooting Java "Error: encoding GBK non-mapped characters"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.