Java日本語のコンパイルエラー解消
以下のコードをコンパイルしようとしてエラーが発生
MyApp.java
import java.io.*;
class MyApp{
public static void main(String[] args) throws IOException
{
System.out.println("文字を入力してください");
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
System.out.println(str + "が入力されました。");
}
}
↓コンパイル実行
javac MyApp.java
↓エラー発生
MyApp.java:11: エラー: この文字は、エンコーディングMS932にマップできません
System.out.println(str + "縺悟?・蜉帙&繧後∪縺励◆");
対処法(コンパイル時のコマンドを変更する)
× javac MyApp.java
↓
〇 javac -encoding utf-8 MyApp.java