[java] Transition from applications to applets...

Started by
5 comments, last by tebriel 18 years, 9 months ago
I've worked with Java applications quite a bit--now I need to start working on web applets. Other than the major obvious differences, does anyone have any "gotchas" or personal experiences with not-so-obvious differences that I should be aware of?
Advertisement
Applets have a security sandbox which does not allow them to do everything - unless they're properly signed, and deployed with a trusted certificate, etc...

Son Of Cain
a.k.a javabeats at yahoo.ca
I know there's tighter security measures--but what I'm interested in is exactly what types of things you can't do.
Heh.. Often, when you have a great idea, you can't implement it with Applets ;)

Kidding, of course. But without signing and certifying your applet, you cannot access the user's file system, and even the server's own. Some I/O operations for networking are also not allowed, like Http connections.

Most of the problems can be overcome with trusted applets, but there are some operations you must call as privileged actions in order to have no problems at all.

It might be better for you to outline what your app needs to do, then we can warn you about the pitfalls of such transitions, before you run into them ;)

Son Of Cain
a.k.a javabeats at yahoo.ca
applets aren't as portable across JRE versions as applications, for some reason. I don't know why, but I've had applets that were basically just wrappers around the same backend code as other applications. The applets needed a recompile for each JRE version and the application was fine for each JRE version.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Here is another thing to keep in mind. I have a program that works as both an app and applet. Besides needing to use a signed jar file to access the hard drive, there we issues involving networking, as well as object creation. Because the application can connect to anyone, but the applet can only connect back to the host it was loaded from, I had to change some stuff. Also, when the applet loads, it uses the start() stop(), init() and destroy() methods. Thing that were being done in the constructor of the app will need to be moved. Another point is that not only does some versions of web browsers call these methods wrong (like explorer calling init() twice sometimes), these methods are called from a different thread than the GUI thread. This involves using the SwingUtilities.invokeLater() or .invokeAndWait() methods.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

That's what I was looking for. IE can call init() twice? Bleh! :p Yeah that could definitely be a strange bug to track down if you weren't aware it could happen.
Thanks, that does help, but I don't have anything specific to use them for yet, I just know I will be in the future.

This topic is closed to new replies.

Advertisement