Java compilation error with special characters in class name

I ran into the problem of compiling the source file with a special character in the class name. The class file compiles in the Eclipse IDE, but not from javac. I believe that I need to use the -encoding flag, but have not yet gotten into the correct setting. 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 to compile on the Windows XP command line
  • Ultimately, this compiler should be part of the ant build, run on different operating systems.
  • I am working on a tool creating this generated source file.
+7
source share
2 answers

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 need to set the locale of your shell so that it uses the correct character encoding.

+7
source

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

0
source

All Articles