Error compiling Java file with special characters in class name

我的梦境 提交于 2019-12-01 16:52:49

问题


I am encountering an issue compiling a source file with a special character in the class name. The class file compiles fine in the Eclipse IDE, but not from javac. I believe I need to leverage the -encoding flag, but haven't hit the right setting yet. I would appreciate any pointers:

File Name: DeptView和SDO.java

Java Source:

public interface DeptView\u548cSDO {

   public int getDeptno();

   public void setDeptno(int value);

}

Error Message:

Running javac *.java results in the following error message:

javac: file not found: DeptView?SDO.java

UPDATE

  • I am currently trying the compile at a Windows XP command prompt
  • Ultimately this compile will need to be part of an ant build, an run on different operating systems
  • I work on the tool that is producing this generated source file.

回答1:


One solution is to list the file name of each compilation unit in a separate file, say files, and pass @files as a command-line argument to javac. Otherwise, you will have to set the locale of your shell, so that it is using the correct character encoding.




回答2:


Have you tried using -encoding UTF8 or -encoding UTF16LE (Little Endian) or -encoding UTF16BE (big endian)? (The usage of LE or BE depends on the system you are using -- Windows is LE from what I remember.)



来源:https://stackoverflow.com/questions/5993979/error-compiling-java-file-with-special-characters-in-class-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!