Code written in Java-TeraPad starting from beginner does not work due to error

Introduction

When I compiled the code written in ** TeraPad ** at the command prompt, it was full of errors. When I wrote it with another text editor, it worked fine, so I left it as it is. I will leave it here as a memorandum, so I will write it as an article.

Execution environment

・ ** Java 11 ** JDK (Java Development Kit) only, eclipse not installed ・ ** TeraPad ** Famous free text editor. The same phenomenon occurred in Notepad of Windows 10. ・ ** Windows 10 ** Confirm that the code works properly at the command prompt.

The problem that was occurring

When compiling a java file created with TeraPad, I get an error and the class file is not generated. ** The output file format should have been set to UTF-8 **, but it doesn't work.

From compilation to execution of helloWorld,Terapad version


C:Users>cd C:JavaSample
C:JavaSample>javac helloWorld.java

helloWorld.java:1:error:This character(0xEF)Is encoding windows-Cannot map to 31j
?Sasso class helloWorld
^
helloWorld.java:1:error:Missing class, interface or enum
?Sasso class helloWorld
         ^
helloWorld.java:3:error:Missing class, interface or enum
        public static void main(String[] args)
                      ^
helloWorld.java:6:error:Missing class, interface or enum
        }
        ^
4 errors

When I searched on the net, it was said that it could be compiled ** if the encoding setting was described as UTF-8, but the result is as follows.

From compilation to execution of helloWorld,Terapad 2nd time



C:Users>cd C:JavaSample
C:JavaSample>javac -encoding UTF-8 helloWorld.java
helloWorld.java:1:error: '\ufeff'Is an illegal character
?class helloWorld
^
helloWorld.java:1:error:Missing class, interface or enum
?class helloWorld
       ^
helloWorld.java:3:error:Missing class, interface or enum
        public static void main(String[] args)
                      ^
helloWorld.java:6:error:Missing class, interface or enum
        }
        ^
4 errors

Currently (2020/2/25)

I put both * Brackets * and * SublimeText3 * in a text editor and created a file for each. As a result, it has been improved and it compiles well. I also confirmed that the code written in Notepad works properly.

From compilation to execution of helloWorld,In the case of another text editor



C:Users>cd C:JavaSample
C:JavaSample>javac helloWorld.java
C:JavaSample>java helloWorld
Hello,World!

Impressions

I don't know why this happened only in TeraPad. Regarding the settings of TeraPad, I used it with various settings according to the instructions in the book about PHP. ** I set the initial character code and saved character code to UTF-8N ** on the "TeraPad UTF-8 conversion" page. I read it a few times and didn't understand it, and other text editors have no problem, so I'm leaving it for now.

Recommended Posts

Code written in Java-TeraPad starting from beginner does not work due to error
Does .dockerignore not work? It's written differently from .gitignore!
Correspond to "error that basic authentication does not pass" in the test code "The story that could not be done"
Simulator does not work: Unable to boot device due to insufficient system resources
@BeforeStep does not work in Tasklet of spring-batch
"Do not show again" check does not work in the warning dialog when starting applet
Hivernate Validator does not work in WAS Liberty environment
Sidekiq-limit_fetch does not work
Docker does not work when DOCKER_HOST is specified in WSL2
[Rails 5] [Turbolinks] What to do when JS does not work due to page transition or browser back