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
A class name is an identifier—a series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ( $ ) that does not begin with a digit and does not contain spaces. Some valid identifiers are Welcome1 , $value , _value , m_inputField1 and button7 .
Open a command prompt window and go to the directory where you saved the java program. Assume it's C:\. Type 'javac MyFirstJavaProgram. java' and press enter to compile your code.
javac : The compiler for the Java programming language. javah : C header and stub generator. Used to write native methods. javap : Class file disassembler.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With