This is how I do it. It seems to also survive editing the post in the visual editor. Note that the div’s id and the argument to getElementById must be identical.
<div id="dyemixer"><script type="text/javascript">// <![CDATA[
document.getElementById('dyemixer').innerHTML = '<applet width="550" height="420" code="DyeMixer.class" archive="https://yehar.com/blog/wp-content/uploads/2009/09/DyeMixer.jar" alt="To use this applet, you need a Java virtual machine (Java plug-in) for your web browser.">';
// ]]></script></div>