3

Let's assume I have an executable JAR file called "ascąś©.jar". When I try to run it with double-click the java.exe process starts but then ends immediately. When I try to run it from cmd.exe with the command: java -jar "ascąś©.jar" it returns:

C:\>java -jar "ascąś©.jar"
Error: An unexpected error occurred while trying to open file asc??ę.

or if there isn't such file in current directory:

C:\>java -jar "ascąś©.jar"
Error: Unable to access jarfile asc╣ťę.jar

Same thing happens when there is a Unicode character in directory name. When the name/path doesn't contain Unicode characters the JAR file runs with no problems.

Does anyone have the same issue? Do I need to change some encoding settings in Java? Where can I do this?

My configuration:

Windows 7 Professional SP1 32-bit EN
Java version: 1.7.0_03
Mariusz Ignatowicz
  • 1,445
  • 2
  • 20
  • 41
  • You can change the Windows command-line encoding with `chcp` but the list of available encodings is fairly limited. See if [this question](http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using) helps. – Álvaro González Feb 21 '13 at 09:27
  • Have you tried "chcp 65001" ? – tbsalling Feb 21 '13 at 09:32
  • @ÁlvaroG.Vicario @tbsalling `chcp 65001`, `850`, `437`, `1251` doesn't work. Besides, I guess changing `chcp` wouldn't fix the problem with running the JAR file by double-clicking on it. – Mariusz Ignatowicz Feb 21 '13 at 09:49

2 Answers2

4

This seems to be an issue known for a long time: the Java launcher cannot handle unicode characters in file names.

Can't you just rename the JAR or temporarily copy it to a file with an all-ASCII name? If you really insist on (or are forced to) using unicode characters in the JAR's file name, you could always write your own launcher that knows how to handle them -- the Eclipse developers did this for their launcher. But it seems to be excessive.

Andreas Mayer
  • 687
  • 5
  • 15
1

Try an 8.3 name

I wasn't able to create a "ascąś©.jar" with my IDE but I did make a Unicode named text file and it looks like this might work:

At the Windows command prompt get the 8.3 file name and then use that in-place of the unicode name:

dir /x *.jar
java -jar ASC~1.JAR
Keith Pinson
  • 1,725
  • 1
  • 14
  • 17