Sign in to follow this  
tebriel

[java] Transition from applications to applets...

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this