1

I've made a java applet in Eclipse, it worked in Eclipse but when I embed in a HTML page it does not work, I've tried it in IE and firefox with the same results.

Next I've tries with a very basic program:

import java.applet.*;
import java.net.*;

public class test extends Applet {
    public void init() {
    }
}

than I've run the code in java, and I've placed this index.html page in the bin folder of my project (where is the .class file), my index file looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

 <body>

 <applet code="test.class">
</applet>

</body>
</html>

But it does not work, here is the error that I get in java console:

Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11 Java HotSpot(TM) Client VM
User home directory = C:\Users\Boros
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


java.lang.UnsupportedClassVersionError: test : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception: java.lang.UnsupportedClassVersionError: test : Unsupported major.minor version 51.0
Mat
  • 202,337
  • 40
  • 393
  • 406
Csabi
  • 661
  • 10
  • 20
  • It looks like you're compiling your applet with a newer version of Java than that supported by your browser. Try compiling with Java 1.4 compatibility flags. – Paul Tomblin Dec 18 '11 at 14:02
  • possible duplicate of [Why is Ant giving me a Unsupported major.minor version error](http://stackoverflow.com/questions/7073485/why-is-ant-giving-me-a-unsupported-major-minor-version-error) – MByD Dec 18 '11 at 14:02
  • It's definitely a version conflict error, you are compiling it with a higher version and running it from a lower version in hierarchy. – nIcE cOw Dec 18 '11 at 14:11

1 Answers1

2

Do check the version of Java used by your Eclipse and the one in your classpath. Seems like you got different versions.

nIcE cOw
  • 24,468
  • 7
  • 50
  • 143