Solution: First use software to open the java file; then use the "ctrl a" key to select all the code in the file, and use the "ctrl c" key to copy the code; then click "Encoding" at the top of the page, and select Select "Use ansi encoding" in the list and use the "ctrl v" key to paste the code; finally save and run.
The operating environment of this tutorial: windows7 system, java10 version, Dell G3 computer.
When such an error occurs, it is usually because the code contains Chinese characters, and the Chinese characters in the comments are also counted. Because when using CMD to run a java program, the system's default encoding format is gbk. Codes containing Chinese characters are generally in UNICODE format, so it is easy to cause coding errors when running codes containing Chinese characters directly.
It is easy to solve the problem once you know the source of the problem. For those who use notpad, you can directly use the transcoding function that comes with the editor.
The encoding conversion position is in the Encoding column. Just convert the encoding to "Use ANSI format encoding".
But if we directly click "Use ANSI format encoding", we will find that the original Chinese characters are garbled, which is obviously not the effect we want.
The correct way is to copy all the source files first, then delete all the codes, and then set the encoding format to "Use ANSI format encoding". After setting Then paste the source file and save it. At this time, you will find that the encoding is in ANSI format.
After modification, we run it again and it works perfectly.
Related free learning recommendations: java basic tutorial
The above is the detailed content of How to solve the unmappable characters in java encoding gbk. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool