Despite the benefits, there are also pitfalls in Java's structure that make protecting source code difficult. Since the security manager isn't checked, once a thread goes native, the security doesn't apply. Garbage collection in Java can also be problematic. In some Java implementations, the garbage collector may copy sensitive memory while it is in use for efficiency, and objects created by a running program are sometimes collected in the garbage heap. The easiest way to protect source code is to not allow the code to be stored magnetically in memory.
Applications have a responsibility to be reasonably secure.
Try to prevent programs from making memory dumps when they crash. Memory dumps are usually stored on the local file system, which may make them easily accessible. Erasing Erasing data from memory may be more difficult than one might think. Deleting usually only means removing a system file entry that points to a file. The file still exists somewhere, until it gets overwritten.