Question about jar.exe's encode

Source: Internet
Author: User
Tags bug id
-Author wonder @ 05:38

 

 

 

 

It seems that I am at war with minicomputers, and I cannot update the programs for life or death this evening. This hpux11i is really troublesome. Most FTP programs are not easy to use. Later, they can only be packaged with jar. After the program is packed, the program is put into HPUX and decompressed with jar. The problem can be solved, and an exception is reported. Java.util.zip. zipinputstream. getutf8string (zipinputstream. java: 298). What should I do? I checked it online and found that it was a bug of sun, and it has not been changed for six years. tnnd and sun cannot work diligently.

No way. I had to try it. I found that there was no problem on the same platform. It was estimated that it was a problem with the encode of the platform, but I didn't find a place to set it. Solution: compress a jar file with jar in windows, upload the file to HPUX using the FTP tool in windows, and then connect to HPUX using the Telnet tool in windows, execute jar xvf to make it easy to use.

At last, we despise Sun's laziness!

 

Bug ID:4820807

 
Votes 9
Synopsis Java.util.zip. zipinputstream cannot extract files with Chinese chars in name
Category Java: classes_util_jarzip
Reported against 1.2.1, 1.4.1, Tiger
Release fixed  
State In progress, request for enhancement
Related bugs 4885817,424 4499
Submit date 19-feb-2003
Description
FULL PRODUCT VERSION :java version "1.4.1"Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)FULL OPERATING SYSTEM VERSION :Microsoft Windows 2000 [Version 5.00.2195]Service Pack 3A DESCRIPTION OF THE PROBLEM :If ZipInputStream is used to read a zip file containing oneor more files with Chinese, Japanese or Korean names, thegetNextEntry method throws an IllegalArgumentException.STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :1. Create a zip file containing at least one file with aChinese, Japanese or Korean filename.2. Try to read using a ZipInputStream.EXPECTED VERSUS ACTUAL BEHAVIOR :Should return a valid entry with the correct filenameinstead of throwing an exception.ERROR MESSAGES/STACK TRACES THAT OCCUR :java.lang.IllegalArgumentException    at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:291)    at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:230)    at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:75)REPRODUCIBILITY :This bug can be reproduced always.---------- BEGIN SOURCE ----------import java.io.FileInputStream;import java.io.IOException;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream;public final class TestCase {    public static void main(String[] args) throws IOException {        ZipInputStream zis = new ZipInputStream(new FileInputStream("myfile.zip"));        ZipEntry entry;        while ((entry = zis.getNextEntry()) != null) {            System.out.println("found " + entry.getName());        }    }}---------- END SOURCE ----------CUSTOMER WORKAROUND :Do not use CJK filenames in zip files.(Review ID: 181382) ====================================================================== xxxxx@xxxxx  2003-09-02Same problem reported by a CAP member from Germany:J2SE Version (please include all output from java -version flag):  java version "1.4.1"  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)  Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)and  java version "1.5.0-beta"  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)  Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)Does this problem occur on J2SE 1.3, 1.4 or 1.4.1?  Yes / No (pick one)  YesOperating System Configuration Information (be specific):  English Linux and German Win2KBug Description:  A ZIP file with entries that contain german umlauts. When read  read these entries using ZipInputStream.getNextEntry() it throws an   IllegalArgumentException at:Exception in thread "main" java.lang.IllegalArgumentException         at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:298)         at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:237)         at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:73)         at ZipUmlauts.main(ZipUmlauts.java:22)  It would be better, if the getUTF8String() method would just ignore   these "illegal" characters or add them "as-is".Test Program: (ZipUmlauts.java umlauts.zip)-------------import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream;/* *  ZipUmlauts.java created on Sep 1, 2003 8:45:08 AM *//** * @version ${Id:} * @author rs * @since pirobaseCB 1.0 */public final class ZipUmlauts {    public static void main(String[] args) throws IOException {        FileInputStream fis=new FileInputStream("umlauts.zip");        ZipInputStream zis=new ZipInputStream(fis);        ZipEntry ze;        while ((ze=zis.getNextEntry())!=null) {            System.out.println(ze.getName());        }    }}
Work around
N/A
Evaluation
Unfortunately, fixing this in a backward-compatible way may be impossible.At least, for non-ASCII file names, Java should be able to create fileson one system and extract them on a different system, even if theencodings are different.The suggestion of adding an encoding attribute is a good one.That should have been done when the decision to encode file namesin UTF-8 was first made. xxxxx@xxxxx  2003-09-04I have confirmed that, as long as one uses Sun's J2SE zipimplementation consistently, in a environment where file.encodingsupports the character set of interest,that one can create, list and extractjar/zip files containing non-ASCII characters (including Chinesecharacters) correctly.   Other zip implementations also havecharacter encoding interoperability problems, so J2SE'simplementation is not alone.The suggestion of falling back to file.encoding is an appealing one,but it's quite dangerous to go down that route.Encoding "autodetection" is a good interactive feature for users, butit's not so good for file formats.  To have a file be properly readabledepending fairly randomly on the data bit patterns stored within itis a reliability disaster.  It's much better to have consistent failurethan intermittent "success".Re-architecting zip to record the encoding of the file names willhopefully get done for J2SE 1.6. xxxxx@xxxxx  2003-11-25I believe this is a duplicate of 4244499. See the evaluation of that bug report for a relatively simple proposed solution. xxxxx@xxxxx  2005-1-29 00:28:38 GMT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.