'IDEA run a sampe code and get the issue: java: illegal character:'#'

IDEA version: 2021.3.2

JAVA version: 1.8.0

The encoding format is UTF-8

I am a beginner in java, I try to install IEDA and run a sample code to output "HelloWorld", then get the error java: illegal character:'#' and other errors

enter image description here

What I tried:

  1. Check the env path, right.

  2. Create a txt file-> enter test code-> change the file type to .java, then run the cmd javac test.java and java xxx, it output HelloWorld

  3. Change the encoding format to GBK and then back to UTF-8

  4. Add -encoding UTF8 in IDEA settings

enter image description here

update1

public class test{
    public static void main(String[] args) {
        System.out.println("Just a test");
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source