Java applet wont run

Posted by Courtney on Stack Overflow See other posts from Stack Overflow or by Courtney
Published on 2014-08-24T04:01:30Z Indexed on 2014/08/24 4:20 UTC
Read the original article Hit count: 178

Filed under:
|
|
|

I am trying to get a Java applet to run properly when linked to an HTML page in Dreamweaver CC. I'm new to all this so please bear with me here. First I saved this code to a .java file

//Triangle.java
import java.awt.*; 
import java.applet.Applet;

public class Triangle extends Applet {

    public void paint (Graphics g){
        int bottomX=80;
        int bottomY=200;
        int base=100;
        int height=100;
        g.drawLine(bottomX,bottomY,bottomX+base,bottomY);
        g.drawLine(bottomX+base,bottomY,bottomX+base/2,bottomY-height);
        g.drawLine(bottomX+base/2,bottomY-height, bottomX,bottomY); 
    }
}

I then compiled it entering javac Triangle.java

After that, I inserted it into a Dreamwever page using:

<html>
    <applet code=Triangle.class width=400 height=400 > 
    </applet>
</html>

Now when I try and open the page in Chrome I get an error reading:

UnsupportedClassVersionError Triangle: Unsupported major.minor version 52.0

This, as I have read, is an issue with using two incompatible Java versions? In my Java Control Panel it says I am using version 1.8.0_20 and my JDK is jdk1.8.0_20.

Does anyone see anything super obvious that I am doing wrong here?

© Stack Overflow or respective owner

Related posts about java

Related posts about html