JDK-5013622 : JVM can't find a class whose name contains non-english character(run from .bat f
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-03-15
  • Updated: 2024-10-07
  • Resolved: 2014-02-25
Related Reports
Relates :  
Relates :  
Description
Name: gm110360			Date: 03/15/2004


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtine Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
Here is my source :
class BonneMatin???e {
	public static void main(String[] arguments) {
		System.out.println("Bonne matin???e");
	}
}
 It's well compiled with javac and well executed with java, when I launch the commands in a DOS Window.

But if a launch the JVM from the following BAT file (in the same directory than BonneMatin???e.java and BonneMatin???e.class):

java BonneMatin???e
PAUSE

The JVM throws the following Exception :

Exception in thread "main" java.lang.NoClassDefFoundError : BonneMatin<the graphical character whose ASCII code is  218>e

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) edit  and compile the following source in the same directory  "foo":

class BonneMatin???e {
	public static void main(String[] arguments) {
		System.out.println("Bonne matin???e");
	}
}

2) edit in the  directory "foo" the following BAT file called BonneMatin???e.bat :
java BonneMatin???e
pause

3) call the bat  file in a DOS Window, from the "foo" directory




EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I am expecting to see the message "Bonne matin???e" printed in the DOS Window
ACTUAL -
Exception in thread "main" java.lang.NoClassDefFoundError : BonneMatin<the graphical character whose ASCII code is  218>e

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NoClassDefFoundError : BonneMatin<the graphical character whose ASCII code is  218>e

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Don't use characters with accents in the name  of the main classe
(Incident Review ID: 243581) 
======================================================================
###@###.### 2004-03-15

Comments
WORK AROUND One can always use these special characters for ClassNames and create a JAR using an IDE such as Netbeans. public class ¿¿¿¿ { public static void main(String... args) { System.out.println("Should print \"namasthe\" in Hindi"); System.out.println("¿¿¿¿¿¿¿"); } } Compile this with an IDE such as Netbeans and produce an executable jar, executing the jar will print the Unicode characters, provided of course the Window in which you are executing supports Unicode. So in cygwin terminal this is what I get: $ c:/jdk1.7.0/bin/java -jar dist/Hindi.jar Should print "namasthe" in Hindi ???????
27-07-2010

EVALUATION This seems to be a combination of issues with cmd, launcher and its file system access.
27-07-2010

EVALUATION To more rapidly investigate this problem, it would be extremely helpful to have a version of the source code with the non-ASCII characters in the name represented using "\u0123" notation. ###@###.### 2004-03-16 Suspect unicode encoding issue with the text bat file; investigating. ###@###.### 2004-03-19 The fact that javac can compile classes with non-ASCII names and that java can run the resulting .class files suggests that java is working perfectly; the problem must be with the program that is invoking java, namely cmd.exe, passing badly encoded arguments to java.exe. You can try other methods of invoking java, e.g. perl -e 'exec "java", "BonneMatin\xe9e"' and see that it works. The above perl command will probably work when embedded in a .cmd file. I don't really understand the encoding mechanism used by cmd.exe, but I have confirmed that using UTF-8 and the "default" java Windows encoding fail. Unfortunately, users of non-ASCII characters are advised to not use them in file names for many years to come. Using non-ASCII characters in file contents is plenty of trouble all by itself. I intend to close this as Not a Bug. ###@###.### 2004-03-19
19-03-2004