Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: What is worng in my java code

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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


  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  3. #3
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: What is worng in my java code

    Hello janakaraj!
    Where is your main method? You need a main method to run your program.

Similar Threads

  1. problem in my code java code graph editeur
    By kisokiso in forum Java Theory & Questions
    Replies: 5
    Last Post: January 6th, 2012, 08:36 AM
  2. Replies: 10
    Last Post: April 5th, 2011, 10:09 AM
  3. What am I doing worng?
    By ThunderChunkier in forum What's Wrong With My Code?
    Replies: 10
    Last Post: March 3rd, 2011, 12:48 AM
  4. Replies: 2
    Last Post: August 1st, 2010, 07:29 AM
  5. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 11:18 PM