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.
・ ** 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.
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
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!
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