How to specify correctly codebase and archive in Java applet?

Attribute codebase specifies the base URL of the applet – the directory that contains the applet’s code. It is used while searching jar files in archive attribute, in such a way that all jars in archive attribute are searched relative to codebase. So. When you use archive=”http://myurl.com/archive/myjar.jar” and codebase=”http://myurl.com/classes” together it means: find “http://myurl.com/archive/myjar.jar“ in … Read more

socket programming multiple client to one server

For every client you need to start separate thread. Example: public class ThreadedEchoServer { static final int PORT = 1978; public static void main(String args[]) { ServerSocket serverSocket = null; Socket socket = null; try { serverSocket = new ServerSocket(PORT); } catch (IOException e) { e.printStackTrace(); } while (true) { try { socket = serverSocket.accept(); … Read more

Why were applets deprecated in JDK 9?

Applets were very popular a couple of years ago, but now the browser world changed and security is becoming a major focus for all major browser vendors. The Java team gave its complete set or reasons, alternatives etc. in the document Migrating from Java Applets to plugin-free Java technologies. On page 4, there is the … Read more

What’s Java Hybrid – Applet + Application?

A hybrid applet/application simply abstracts the initialization of two top-level containers, JFrame and JApplet. Examples are seen here, here and here. Addendum: How does that work? The first example exposes a factory method, createGUI(), and it adds the returned panel to the extant top-level container. The second provides a static initContainer() method, passing the enclosing … Read more