unsupported major.minor version 49.0 - When deplyoing an applet

I have read other post related to this problem yet none have solved my problem.

I have an application that has been compiled as a Jar in Java 1.5.

The application has two entry points one as an applet and the other a JFrame.

The JFrame works correctly deployed as an executable jar and a signed jar for java web start. However when I wish to use it as an applet I get the following errors:

When I launch it in Applet Viewer I get:

unsupportedClassVersionError: (unsupported major.minor version 49.0)

When I launch it in IE6 I get:

load: GPTool.Applet_Interface.class can't be instantiated.

java.lang.InstantiationException: GPTool.Applet_Interface

The odd thing is that it is deployed in Java 1.5 and developed and compiled in Java 1.5.There are no previous installations of Java on my computer.

I would very much appreciate your input on this annoying problem, I am tearing my hair out.

Andrew.

[969 byte] By [scottie_uka] at [2007-10-3 8:58:20]
# 1

Well futher investigation tells me that the errors generated by the applet viewer were missleading.

This is becauses their was infact another version of Java runnong on my computer when I thaught that there was not. I have removed this version of Java both errors are now consistant with each other in both the appletviewer and web page.

This indicates that there must be a fundimental error in my code...

I will keep you posted.... I know its handy for those experiencing similar problems to view this....

Message was edited by:

scottie_uk

scottie_uka at 2007-7-15 4:08:52 > top of Java-index,Desktop,Core GUI APIs...
# 2

Take a look at the entry class for my applet is there any reason you can see why it cannot be instanciated?

Ignore the spelling errors they are consistant.

Thanks

Andrew

package GPTool;

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

import java.awt.BorderLayout;

import java.awt.Dimension;

import javax.swing.JPanel;

import javax.swing.JLabel;

import java.awt.Font;

import java.awt.Color;

import java.awt.Rectangle;

import java.beans.PropertyChangeEvent;

import java.beans.PropertyChangeListener;

public class Applet_Interface extends JApplet implements User_Interface {

//The settings for Progranimate are reteived from this class

public CurrentSettings currentSettings;

//Call instance of workspace

public Workspace workspace;

//Call instance of the pallete

public Pallete pallete;

//call instance of menubars

public Menus menus;

//add layout manager for this frame

private BorderLayout borderLayout1;

//add toolbar to this frame

public ToolBar toolBar;

//add the info panel at bottom of ui

private JPanel pnlBottomInfo = new JPanel();

private JLabel lblBottomPanelLabel = new JLabel();

//the code translator for the entire program

public CodeTranslator codeTranslator;

//The Glodal Variable Ispector

public VariableInspector varInspec;

//The file to load in at start up

public static String loadFile = "";

public static String loadURL = "";

public static Applet_Interface user_Interface;

//============================================================================

//Constructor for this class

//============================================================================

public Applet_Interface (String lFile, String lURL)

{

//initialise classes

currentSettings = new CurrentSettings();

menus = new Menus(currentSettings);

borderLayout1 = new BorderLayout();

toolBar = new ToolBar();

varInspec = new VariableInspector(this,getTranslator(),currentSettings);

workspace = new Workspace(getBoandaries (),this,menus);

varInspec.setWorkspace(workspace);

pallete = new Pallete(this);

try

{

jbInit(lFile,lURL);

}//end try

catch(Exception e)

{

e.printStackTrace();

}//end catch

}//end constructor ===========================================================

//============================================================================

// Method jbInit

// Initialises the components used by this application

//============================================================================

private void jbInit(String lFile, String lURL) throws Exception

{

//The files to be loaded on startup

loadFile = lFile;

loadURL = lURL;

//set menuBar in place

this.setJMenuBar(menus);

//Add layout manager

this.getContentPane().setLayout(borderLayout1);

//set up user interface defaults==========================================

// set user interface to size of screen dimensions

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

toolBar.setMaximumSize(new Dimension(1152, 60));

toolBar.setMinimumSize(new Dimension(1152, 60));

toolBar.setBounds(new Rectangle(0, 0, 1142, 60));

toolBar.setSize(new Dimension(1142, 60));

toolBar.setPreferredSize(new Dimension(1152, 60));

//Add toolBar to this interface==========================================

this.getContentPane().add(toolBar, BorderLayout.NORTH);

//add the variable inspector to this interface container panel============

this.getContentPane().add(varInspec,BorderLayout.EAST);

//add a pallete to this interface container panel========================

this.getContentPane().add(pallete, BorderLayout.WEST);

//add a workspace to this interface container panel=======================

this.getContentPane().add(workspace, BorderLayout.CENTER);

workspace.setBackground(Color.lightGray);

//workspace.setBounds(new Rectangle(110, 60, 1032, 720));

//workspace.setPreferredSize(new Dimension(1032, 720));

//workspace.setSize(new Dimension(1032, 720));

//add the info panel at the bottom of ui==================================

pnlBottomInfo.setBackground(Color.lightGray);

lblBottomPanelLabel.setFont(new Font("Tahoma", 0, 16));

lblBottomPanelLabel.setText("Program (prototype) ?Andrew Scott 2006");

pnlBottomInfo.add(lblBottomPanelLabel, null);

this.getContentPane().add(pnlBottomInfo, BorderLayout.SOUTH);

//UI Defaults for proganimate=============================================

this.setSize(screenSize);

//make user interface visible

this.setVisible(true);

this.setVisible(true);

//Setup menu listeners this class

menuListeners();

////////////////////////////////////////////////////////////////////////

//Load in the specified file if loadFile is not an empty Sting.

////////////////////////////////////////////////////////////////////////

if (loadFile.equals("") == false)

{

workspace.autoLoadFile(loadFile,false);

loadFile = "";

this.repaint();

}//end if

else if (loadURL.equals("") == false) {

workspace.autoLoadFile(loadURL,true);

loadURL = "";

this.repaint();

}//end else if

}//end jbInit===============================================================

//=========================================================================

//Method getCurrentSettings

//Returns a copy of the current application settings

//=========================================================================

public CurrentSettings getCurrentSettings () {return currentSettings;}

//=========================================================================

//Method getToolBar

//Returns a copy of the toodBar

//=========================================================================

public ToolBar getToolBar (){return toolBar;}

//=========================================================================

//method:getPallete

//Returns the Pallete to the calling class

//=========================================================================

public Pallete getPallete () {return pallete;}

//=========================================================================

//method:getWorkspace

//Returns the Workspace to the calling class

//=========================================================================

public Workspace getWorkspace () {return workspace;}

//=========================================================================

//method:getVariableInspector

//Returns the VariableInspector to the calling class

//=========================================================================

public VariableInspector getVariableInspector() {return varInspec;}

//=========================================================================

//method:getTranslator

//Returns the translator to the asking class

//=========================================================================

public CodeTranslator getTranslator () { return codeTranslator; }

//=========================================================================

//method:setTranslator

//Sets the translator for this class and the whole program.

//=========================================================================

public void setTranslator (CodeTranslator ct) { codeTranslator = ct; }

//===========================================================================

//Method: getBoundariesReturns: Dimension

//Calculates the dimensions of the screen size and returns the dimensions

//avaliable for the workspace.

//===========================================================================

public Dimension getBoandaries ()

{

int m = 115;//pallete.getWidth(); //the with of the component bar.

int v = 250;//arInspec.getWidth(); //the width of the variable inspector

int t = 45;//toolBar.getHeight(); //the height of the toolBar,

// int b = 0; //pnlBottomInfo.getHeight();//the height of the bottom bar;

//get the size of the screen

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

//calculate size of work area avaiable

Dimension dim = new Dimension ((m+v - screenSize.width) *-1,((t+v - screenSize.height)*-1)+144);

//dim = new Dimension(792,724);

return dim;

}//==========================================================================

//============================================================================

//MenuListenrers()

//Sets up the action listeners for the menu items

//============================================================================

private void menuListeners()

{

//Advanced Settings listener

menus.menuFileAdvancedSettings.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

advancedSettings_Clicked();

}

});

}//=========================================================================

//############################################################################

//############################################################################

//##EVENT HANDLERS GO HERE ##

//############################################################################

//############################################################################

//exit the application when the close button is clicked=====================

private void this_windowClosing()

{

System.exit(0);

}//==========================================================================

//Advanced Settings Listener================================================

private void advancedSettings_Clicked()

{

final SettingsPanel sp = new SettingsPanel(currentSettings);

sp.setVisible(true);

sp.addPropertyChangeListener (new PropertyChangeListener()

{

public void propertyChange(PropertyChangeEvent e)

{

applySettings( (CurrentSettings)e.getNewValue());

sp.dispose();

}

});

}//========================================================================

//=========================================================================

//Method: applySettings

//Applys the settings of the settings pan

//=========================================================================

private void applySettings (CurrentSettings c) {

currentSettings = c;

workspace.applySettings(currentSettings);

}//=========================================================================

//############################################################################

//############################################################################

//##WHERE IT ALL BEGINS THE MAIN METHOD ##

//############################################################################

//############################################################################

//============================================================================

//Method: Main

//The mian applicaton calling method

//============================================================================

public static void main(String[] args)

{

loadFile ="";

loadURL="";

try

{

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");

if (args.length > 0)

{

//if the 1st argument specifies web a Web Start program then check for file URL

if ((args[0].equalsIgnoreCase("W") | args[0].equalsIgnoreCase("WEB"))& args.length == 2)

{

//get the file to be loaded in

if (args.length == 2)

loadURL = args[1];

}//end if

//if the 1st argument specifies a Local program then check for file.

else if ((args[0].equalsIgnoreCase("L") | args[0].equalsIgnoreCase("LOCAL"))& args.length == 2 )

{

//get the file to be loaded in

if (args.length == 2)

loadFile = args[1];

}//end else if

else if (args.length == 1)

{

//get the file to be loaded in

if (args.length == 2)

loadFile = args[0];

}//end else if

}//end if

}//end try

catch(Exception e)

{

e.printStackTrace();

}//end catch

user_Interface = new Applet_Interface(loadFile,loadURL);

}//end main===================================================================

Message was edited by:

scottie_uk

scottie_uka at 2007-7-15 4:08:52 > top of Java-index,Desktop,Core GUI APIs...
# 3

I have now resolved this problem:

The class structure show above is not correct when implimenting applets. I feel a bit silly now, this is what you get for not reading the documentation properly. A valuable lesson many should heed..

to instantiate an applet you call the init method not the main method.

Oh silly old me.

scottie_uka at 2007-7-15 4:08:52 > top of Java-index,Desktop,Core GUI APIs...
# 4

Solved

Just do these things.... If you initially complied your classes in jdk1.5 and if u r trying to run the same in 1.4.2 or other.. The already compiled classes will be expecting jdk 1.5 JRE for their runtime execution. So what u have to do is......

1.stop ur sever

2.delete the work directory in tomcat

3.Delete the work directory in your projects web-app Folder

4.Now cleann the project... Build... and Run Again ... . It should work...

if still it dont , i prefer use only jdk1.4.2 on system.. set enviorment variebles for it...Reinstall tomcat .. and do above mentioned steps ,,, This should solve the problem...

Message was edited by:

sunildm4u

sunildm4ua at 2007-7-15 4:08:52 > top of Java-index,Desktop,Core GUI APIs...