7

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.
6
  • Bleugh, why are there special characters in the class name in the first place? I take it this isn't your doing ;) Commented May 13, 2011 at 15:15
  • 1
    Can you not simply rename the class and source file? Seems odd to me to use non-ASCII characters in a class name. Commented May 13, 2011 at 15:15
  • It looks like he's using source code from another team, or something. For compatibility reasons, it'd be a pain to rename. Commented May 13, 2011 at 15:16
  • 2
    @Chris Dennett and @Bernard - The source file is auto generated. Renaming is not an option for this particular use case. Commented May 13, 2011 at 15:19
  • Which OS with which settings is used? Which process/program writes the filename into the directory? Commented May 13, 2011 at 15:32

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

+1: I suspect it is not a problem with the javac program itself, but rather with the shell.
+1 - At this point I believe the problem is due to the character encoding of the Windows command window I am using as I am able to compile this in Eclipse and with javac on Linux.
0

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.)

1 Comment

Thanks for the input. I just tried those encodings, but I'm still getting the same error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.