Java Applet Programming Tip


My newest project is a Java Applet game (still hush hush on the details tho…) and I thought I’d share a nice little tip for securing a java applet so that it can only be run from within your webpage and not from anybody elses.

This is particularly useful if you don’t want others to profit by embedding your game in their site.

The code is simple

// check host
String hostname = getDocumentBase().getHost();
if (hostname.equals("www.peachysoft.com"))
{
// All is well run the applet
}
else
{
// dont run the applet
}

  1. #1 by U_Z on November 6, 2007 - 11:56 pm

    Thanks for the tip!

(will not be published)