Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a resource JAR with filenames including umlauts?

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.

like image 660
Willi Mentzel Avatar asked Oct 31 '12 14:10

Willi Mentzel


1 Answers

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.

like image 186
Willi Mentzel Avatar answered Nov 01 '22 12:11

Willi Mentzel