How to load a resource JAR with filenames including umlauts?
Asked Answered
D

1

10

I am working on a Java Webstart Application. This is supposed to gather resources from a JAR file that is included in the resources section in the JNLP file.

The application language is German, so some of the folders/files in the JAR include the characters 'ä', 'ö', 'ü' or 'ß'. If I start this application the following exception is thrown:

java.lang.IllegalArgumentException: MALFORMED
at java.util.zip.ZipCoder.toString(Unknown Source)
at java.util.zip.ZipInputStream.readLOC(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at com.sun.deploy.net.HttpDownloadHelper.decompressWrite(Unknown Source)
at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
at com.sun.deploy.cache.Cache.downloadResourceToTempFile(Unknown Source)
at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source)
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

If I open the JAR file in notepad++ is says the encoding is ANSI. So, I change it to UTF-8 but then it doesn't even compile.

I am using Netbeans 7.2. For development I include the JAR file as library and this way it is listed in the resources section.

Devereux answered 31/10, 2012 at 14:24 Comment(0)
D
2

I now used the JAR tool from the JDK like this

jar cf <jar-file-name> <input-file(s)>

and it worked fine.

I don't exactly understand why it works because the encoding of the JAR file that is produced is still ANSI.

Devereux answered 1/11, 2012 at 18:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.