Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Swing help: Japplet not displayed in browser



My RegApp.java file contains following code :

import java.applet.Applet;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import java.awt.*;
/*

*/
public class RegApp extends JApplet implements ActionListener
{
JButton submit=new JButton("Submit");
JButton cancel=new JButton("Cancel");
JTextField cname=new JTextField(20);
JTextField ceid=new JTextField(20);
JTextArea caddr=new JTextArea(3,1);
JLabel lblname=new JLabel("Name");
JLabel lbleid=new JLabel("E-mail_id");
JLabel lbladdr=new JLabel("Address");

public RegApp()
{

}
public void init()
{
Container app = getContentPane();
app.setLayout(new GridLayout(7,2));
app.add(lblname);
app.add(cname);
app.add(lbleid);
app.add(ceid);
app.add(lbladdr);
app.add(caddr);
app.add(submit);
app.add(cancel);
cancel.addActionListener(this);
submit.addActionListener(this);
app.setVisible(true);
app.setSize(300,400);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==cancel)
{
cname.setText("");
ceid.setText("");

caddr.setText("");
}
}
}
------------------------------------------------------------------------------------------------------------------------------

I created Customer.html file in the same folder as of the RegApp.java file to display the Japplet ,
code of html file:

----------------------------------------------------------------------------------------------------------------------------------
the applet is not displayed in the browser and shows following error :

Java Plug-in 1.6.0_23
Using JRE version 1.6.0_23-b05 Java HotSpot(TM) Client VM
User home directory = C:\Users\Prashant

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

java.lang.UnsupportedClassVersionError: file:///C:/Program Files/Java/eclipse/mywork/RegApp/src/RegApp : 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: file:///C:/Program Files/Java/eclipse/mywork/RegApp/src/RegApp : Unsupported major.minor version 51.0

can neone please help me out i m trying the above simple program but cant get thru