What is worng in my java code
i got the below error when i run client.java class.
Exception in thread "main" java.lang.NoSuchMethodError: main
i set classpath,path,java_home variables..still im getting error..
How to solve this error..
Here is my code..
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.net.*;
import javax.swing.*;
class Client extends JFrame implements ActionListener
{
Button Send,Clear,Exit;
TextField SystemName,SystemIp,ReceiverName,ReceiverIp,Sender Name,SenderIp;
TextField SenderPassword;
Label n1,n2,n3,n4,n5;
Byte str[];
Client()
{
super("Sender");
Container c = getContentPane();
setSize(400,300);
setResizable(false);
JPanel jp = new JPanel();
jp.setLayout(null);
SenderName= new TextField(20);
SenderPassword = new TextField(20);
SenderPassword.setEchoChar('*');
ReceiverName=new TextField(20);
n3= new Label("SENDERNAME :",Label.LEFT);
n4= new Label("SENDERPASSWORD:",Label.LEFT);
n5= new Label("RECEIVERNAME :",Label.LEFT);
//n6= new Label("RECEIVER-IP :",Label.LEFT
Send=new Button("Send");
Clear=new Button("Clear");
Exit=new Button("Exit");
jp.add(n3);
jp.add(SenderName);
jp.add(n4);
jp.add(SenderPassword);
jp.add(n5);
jp.add(ReceiverName);
jp.add(Send);
jp.add(Clear);
jp.add(Exit);
c.add(jp);
n3.setBounds(40,25,120,25);
SenderName.setBounds(200,25,120,25);
n4.setBounds(40,70,140,25);
SenderPassword.setBounds(200,70,120,25);
n5.setBounds(40,115,120,25);
ReceiverName.setBounds(200,115,120,25);
Send.setBounds(80,200,50,25);
Clear.setBounds(140,200,50,25);
Exit.setBounds(200,200,50,25);
Send.addActionListener(this);
Clear.addActionListener(this);
Exit.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String st;
st=ae.getActionCommand();
if(st.equals("Send"))
{
try
{
SwingMes sm = new SwingMes(this);
sm.setVisible(true);
setVisible(false);
}
catch(Exception e)
{
//System.out.println(e);
}
}
else if(st.equals("Clear"))
{
SenderName.setText("");
SenderPassword.setText("");
ReceiverName.setText("");
}
else if(st.equals("Exit"))
{
System.exit(0);
}
}
}
Thanks in Advance..
Regards,
Janakaraj.P
Re: What is worng in my java code
Hi,
Could you use the tags in order to show code in this post. Is clear see it in that way, not in the way you already posted. When you are going to post, click in the option "Go Advanced" and use the tag "#", in order to show your code.
Regards,
____________
Oscar Gómez
Engineer at PSL
PSL S.A. - CMMi 5 nearshore software development and IT outsourcing from Latin America - Home
Re: What is worng in my java code
Hello janakaraj!
Where is your main method? You need a main method to run your program.