class, interface or enum expected

Hi, i get the error"class, interface or enum expected" when i try to compile

a program. I don't understand what i've done wrong.

import org.snmp4j.CommunityTarget;

import org.snmp4j.ScopedPDU;

import org.snmp4j.Snmp;

import org.snmp4j.TransportMapping;

import org.snmp4j.smi.VariableBinding;

import org.snmp4j.smi.OID;

import org.snmp4j.smi.OctetString;

import org.snmp4j.smi.TimeTicks;

import org.snmp4j.smi.UdpAddress;

import org.snmp4j.transport.*;

import org.snmp4j.event.ResponseEvent;

import org.snmp4j.PDU;

import java.io.IOException;

import org.snmp4j.tools.console.SnmpRequest;

import java.awt.event.*;

import java.awt.FlowLayout;

import javax.swing.event.*;

import javax.swing.*;

import java.util.EventListener;

import java.util.*;

class Startextends Grafikimplements ActionListenerthrows (IOException er){}{

publicstaticvoid main(String []arg){

privateint GET;

String actionName;

String Routingtable ="1.3.6.1.2.1.4.21";

String Interfaces ="1.3.6.1.2.1.2.1";

String IpAddrtable ="1.3.6.1.2.1.4.34";

TimeTicks Ticks =new TimeTicks();

UdpAddress Addr =new UdpAddress(161);

VariableBinding s =new VariableBinding();

OctetString oct =new OctetString("snmp-server");

CommunityTarget target =new CommunityTarget(Addr,oct);

DefaultUdpTransportMapping transport =new

DefaultUdpTransportMapping(Addr);

Snmp snmp =new Snmp(transport);

PDU pdu=new PDU();

SnmpRequest request=new SnmpRequest(null);

// Skicka PDU

public Start(){

super.addMyActionListener(this);

}

publicvoid actionPerformed(ActionEvent event){

actionName = event.getActionCommand();

if (actionName.equals(button_3)){

try{

transport.listen();

pdu.setType(GET);

pdu.addOID(new VariableBinding(new OID("1.3.6.1.2.1.4.34")));

ResponseEvent response = snmp.send(pdu,target);

PDU responsePDU=response.getResponse();

String resp=responsePDU.toString();

textArea.append(resp);}catch(IOException e){}

}

elseif(actionName.equals(button_2)){

try{

transport.listen();

pdu.setType(GET);

pdu.addOID(new VariableBinding(new OID("1.3.6.1.2.1.2.1")));

ResponseEvent response=snmp.send(pdu, target);

PDU responsePDU=response.getResponse();

String resp=responsePDU.toString();

textArea.append(resp);

}catch(IOException e){}

}

elseif(actionName.equals(button_1)){

try{

transport.listen();

pdu.setType(GET);

pdu.addOID(new VariableBinding(new OID("1.3.6.1.2.1.4.34")));

ResponseEvent response=snmp.send(pdu, target);

PDU responsePDU=response.getResponse();

String resp=responsePDU.toString();

textArea.append(resp);}catch (IOException e){}

}

}

public String uptime(){

TimeTicks Ticks = request.getSysUpTime();

String UpTime = Ticks.toString();

return UpTime;

}

publicvoid onResponse(ResponseEvent response){

System.out.println("Response =" + response.getResponse());

}

}

class Grafikextends JFrame{

JButton button1;

JButton button2;

JButton button3;

JTextArea textArea;

String button_1 ="button1";

String button_2 ="button2";

String button_3 ="button3";

public Grafik(){

button1 =new JButton("Knapp");

button1.setActionCommand(button_1);

//button1.addActionListener(this);

button2 =new JButton("Knapp");

button2.setActionCommand(button_2);

//button2.addActionListener(this);

button3 =new JButton("Button3");

button3.setActionCommand(button_3);

//button3.addActionListener(this);

//initiering

setTitle("text");

setSize(400, 400);

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

setLayout(new FlowLayout());

// knappen och lyssnaren

// textruta

textArea=new JTextArea();

textArea.setLineWrap(true);

add(button1);

add(button2);

add(button3);

add(textArea);

setVisible(true);

}

publicvoid addMyActionListener(ActionListener listener){

button1.addActionListener(listener);

button2.addActionListener(listener);

button3.addActionListener(listener);

}

publicvoid removeMyActionListener(ActionListener listener){

button1.removeActionListener(listener);

button2.removeActionListener(listener);

button3.removeActionListener(listener);

}

}

[8934 byte] By [Gimlia] at [2007-11-27 1:01:30]
# 1
...throws (IOException er){} {See the { } in your code? That's where your class ends... Remove that, and you're fine.
SurfManNLa at 2007-7-11 23:36:23 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks, when removing the {} i get a message, '{' expected. Why?, there shouldn't be any more '{' ?
Gimlia at 2007-7-11 23:36:23 > top of Java-index,Java Essentials,Java Programming...
# 3
I'd check the '{' and '}'. The main method doesn't appear to close either.
Simeona at 2007-7-11 23:36:23 > top of Java-index,Java Essentials,Java Programming...
# 4

You need to format the code sanely.

Only one { or } per line. The } braces should be the first (and possibly only) thing on the line and they must be exactly below the first character on the line with the matching {. Use either tabs or spaces throughout, but not both (spaces are better if you're posting here). *

It's not rocket science. But it must be done or your code won't compile. Ever.

(* Well, variations are possible...)

pbrockway2a at 2007-7-11 23:36:23 > top of Java-index,Java Essentials,Java Programming...
# 5

Thanks for the response.

My main method does close properly.

Can you spot anything else that might be the cause, casue i can't....

Other than that it also complains about the constructor

public Start() {

super.addMyActionListener(this);

}

Ileagal start of Expression am i not allowed to do that?

Gimlia at 2007-7-11 23:36:24 > top of Java-index,Java Essentials,Java Programming...
# 6
You can't declare a class to throw an exception, so remove the "throws (IOException er) {}" part from the class declaration.
Herko_ter_Horsta at 2007-7-11 23:36:24 > top of Java-index,Java Essentials,Java Programming...