Jump to content
  • Advertisement
Sign in to follow this  
tebriel

[java] Transition from applications to applets...

This topic is 4904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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

Share this post


Link to post
Share on other sites
I know there's tighter security measures--but what I'm interested in is exactly what types of things you can't do.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!