0 votes
by (130 points)

Hello, I currently am trying to see if I can get a simple applet to work in twine. I have a java applet called Demo.class that draws some graphics on the screen. The applet's code is as follows:

import java.awt.*;

public class Demo extends java.applet.Applet
{
	public void init()
	{
		
	}
	
	public void paint(Graphics g)
	{
		g.drawOval(0, 0, 250, 100);
		g.setColor(Color.RED);
		g.drawString("First Applet", 10, 50);
	}
}

When I try to embed the applet into my twine, I get either nothing (when i try using the applet or object tag) or an error saying it may have been moved or deleted (when I use the embed tag). My html is as follows:

<h1>Applet Test</h1>

<embed src="Demo.class" width="300" height="300"/>

I have used Java before but am new to html. I am currently using the sugarcube format but have tried using others with no success.

1 Answer

+1 vote
by (68.6k points)
edited by

If you're confusing Java for JavaScript, then save for the unfortunate name similarity, due to idiotic marketing shenanigans, they are completely unrelated languages.  You cannot natively run Java code in browsers.

Elsewise, see the Stack Overflow question How to embed a Java applet in a web page? for more information (in addition to the hints given here, the first answer has links to tutorials at Oracle).

...