简体   繁体   English

尝试编译Java程序时编码Cp1252的不可映射字符

[英]Unmappable character for encoding Cp1252 when trying to compile Java program

I tried making a Hello World program in Java, but am getting a CP1252 error: 我尝试用Java创建Hello World程序,但是我收到了CP1252错误:

import acm.program.*; 
public class test extends Program
{
    public void run() { println(”Hello world!!!”); }
} 

Here's the errors: 这是错误:

C:\>javac -cp acm.jar test.java
test.java:4: error: unmappable character for encoding Cp1252
public void run() { println(ÔÇ?Hello world!!!ÔÇ?);
                              ^
test.java:4: error: unmappable character for encoding Cp1252
public void run() { println(ÔÇ?Hello world!!!ÔÇ?);
                                               ^
test.java:4: error: ';' expected
public void run() { println(ÔÇ?Hello world!!!ÔÇ?);
                                          ^
test.java:4: error: not a statement
public void run() { println(ÔÇ?Hello world!!!ÔÇ?);
                                             ^
test.java:5: error: reached end of file while parsing
}
 ^
5 errors`

The simple test.java program is obviously correct and I don't know what the issue is. 简单的test.java程序显然是正确的,我不知道是什么问题。

How do I resolve the CP1252 encoding error? 如何解决CP1252编码错误?

The issue is that you're using smart quotes instead of the actual quote character. 问题是您使用的是智能引号而不是实际的引号字符。

Here's a 'fixed' version of your code: 这是您的代码的“固定”版本:

import acm.program.*; 
public class test extends Program
{
    public void run() { println("Hello world!!!"); }
} 

Note the difference between " and . 注意"之间的区别。

To fix this (and it depends on your keyboard, I think), you should be using the " character that's immediately to the left of your Enter key. 要解决这个问题(我认为这取决于您的键盘),您应该使用" Enter键左侧的"字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM