function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JimHylandJimHyland 

Invoking a Java applet from VF page?

I have searched extensively for a solution of how to call a Java applet from a VF page and I cannot find a working example.  I have the following applet, which works fine the browser:

 

import javax.swing.*;
import java.awt.*;

public class ExampleApplet extends JApplet
{
  public void init() {

 }

  public void paint(Graphics g)
  {
    setBackground(Color.white);
    g.drawString("Test String", 25, 30);
  }
}

 

The following VF page:

 

<apex:page StandardController="Demo_Object__c">

<h1>Applet Test

</h1><html><HEAD></HEAD><p>Starting applet</p>

<BODY BGCOLOR="000000">

<CENTER>

<APPLET

name = "MyExApplet"

code = "ExampleApplet.class"

codebase = "{!$Resource.ExApplet}"

width = "500"

height = "300"

>

</APPLET>

</CENTER>

</BODY>

</html>

</apex:page>

 

I have set up the applet as a static resource called ExApplet.

 

The VF page opens, but the applet fails.  There is a very brief error message saying class file not found.

 

Can someone help me with this.  It seems like a simple problem, but there are no complete examples I can find after several hours of searching.

 

Thanks.

drprokschdrproksch

Hi Jimy,

 

you have to use the codebase attribute in the applet e.g. <applet codebase="{!URLFOR($Resource.Tetris,'')}" code="Tetris.class" 

 

Hth