Search code examples
javaappletinternet-explorer-9

Java Applet not showing on IE 9


I'm trying to access a Java Applet from IE 9. I'm using this code to create the applet:

var attributes = {
    id:'idApplet',
    code:'some.package.PrintApplet.class',
    archive:'Applet.jar',
    codebase:'<%=base_url%>/public/jar/',
    width:400,
    height:400
};

var parameters = {
    // Some parameters
};

var version = '1.5' ;

deployJava.runApplet(attributes, parameters, version);

But I'm getting this in my .jsp page:

enter image description here

This is the code of my applet:

public class PrintApplet extends Applet{

    // Some parameters

    public void init() {
        System.out.println("Started");
    }

    public void useLocalPrinter() {
        //some actions

    }
}

Solution

  • If anyone has this problem again, it's very simple. I was exporting my JAR from Rational Application Developer (Eclipse based) and it wasn't being recognized by the JRE. I have to use ANT to compile my JAR and the problem was gone.

    The ant snippet that i used was this:

    <project name="applet" default="jar" basedir=".">
    
            <property name="jar.home" value="${basedir}/lib" />
            <property name="src.home" value="${basedir}/src-applet" />
            <property name="build.home" value="${basedir}/build-applet" />
            <property name="classes.home" value="${build.home}/classes" />
            <property name="jar.name" value="wami_audio_applet.jar" />
            <property name="jar.path" value="${jar.home}/jar.name" />
    
            <property name="compile.debug" value="true" />
            <property name="compile.deprecation" value="false" />
            <property name="compile.optimize" value="true" />
    
            <path id="compile.classpath">
                    <pathelement location="${basedir}/lib" />
            </path>
    
            <target name="all" depends="clean, prepare, jar"/>
    
            <target name="clean">
                    <delete dir="${jar.path}" />
                    <delete dir="${classes.home}" />
            </target>
    
            <target name="prepare">
                    <mkdir dir="${build.home}" />
                    <mkdir dir="${jar.home}" />
                    <mkdir dir="${classes.home}" />
            </target>
    
            <target name="compile" depends="prepare">
                    <mkdir dir="${classes.home}" />
                    <javac srcdir="${src.home}" destdir="${classes.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" target="1.5">
                            <classpath refid="compile.classpath" />
                    </javac>
            </target>
    
            <target name="jar" depends="compile" description="Make the jar">
                    <jar jarfile="${jar.home}/${jar.name}" basedir="${classes.home}">
                    </jar>
            </target>
    </project>