Security

I don’t know if there was one most frequently asked question about the first edition of Java Network Programming, but there was definitely one most frequent answer, and it applies to this edition too. My mistake in the first edition was hiding that answer in the back of a chapter that most people didn’t read. Since that very same answer should answer an equal number of questions from readers of this book, I want to get it out of the way right up front (and then repeat it several times throughout the book for readers who habitually skip prefaces):Java’s security constraints prevent almost all the examples and methods discussed in this book from working in an applet.

This book focuses very much on applications. Untrusted Java applets are prohibited from communicating over the Internet with any host other than the one they came from. This includes the host they’re running on. The problem may not always be obvious—not all web browsers properly report security exceptions—but it is there. In Java 1.2 and later, there are ways to relax the restrictions on applets so that they get less limited access to the network. However, these are exceptions, not the rule. If you can make an applet work when run as a standalone application and you cannot get it to work inside a web browser, the problem is almost certainly a conflict with the browser’s security manager.

Get Java Network Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.