Sun JDK is not compatible with the ibm jdk Memorandum

Source: Internet
Author: User

If Sun JDK is incompatible with ibm jdk at work, let's take a note.

1. String. getbytes (string encoding)

Testcase: public static void main (string [] ARGs ){
Try {
Randomaccessfile F = new randomaccessfile ("test.txt", "RW ");
F. Write ("TETS". getbytes (null ));
F. Close ();
} Catch (ioexception e ){
E. printstacktrace ();
}
} Sun JDK 1.4: OK

Ibm jdk 1.4:

Exception in thread "Main" Java. Lang. nullpointerexception
At java. Lang. stringcoding $ encodercache. makeencoder (stringcoding. Java: 198)
At java. Lang. stringcoding $ 2.run( stringcoding. Java: 251)
At java. Security. accesscontroller. doprivileged1 (native method)
At java. Security. accesscontroller. doprivileged (accesscontroller. Java: 351)
At java. Lang. stringcoding $ encodercache. getencoder (stringcoding. Java: 248)
At java. Lang. stringcoding. getencoder (stringcoding. Java: 331)
At java. Lang. stringcoding. encode (stringcoding. Java: 472)
At java. Lang. String. getbytes (string. Java: 947)
At nullencoding. Main (nullencoding. Java: 12)

2. Japanese Encoding

Test Case: public static void main (string [] ARGs ){
Try { "".Getbytes (" Shift_jis");
"".Getbytes (" Shift-JIS");
} Catch (exception e ){
E. printstacktrace ();
}
}

Sun JDK 1.4: OK

Ibm jdk 1.4:

Java. Io. unsupportedencodingexception:Shift-JIS
At java. Lang. stringcoding $ encodercache. getencoder (stringcoding. Java: 262)
At java. Lang. stringcoding. getencoder (stringcoding. Java: 331)
At java. Lang. stringcoding. encode (stringcoding. Java: 472)
At java. Lang. String. getbytes (string. Java: 947)
At shiftencoding. Main (shiftencoding. Java: 17)

 

To be continue...

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.