Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Exception in thread"main java.lang.Error:Unresolved compilation problem:at client:5

  1. #1
    rakshitha is offline Member
    Join Date
    Apr 2015
    Posts
    2
    Rep Power
    0

    Default Exception in thread"main java.lang.Error:Unresolved compilation problem:at client:5

    import java.io.*;
    import java.net.*;

    class serverj
    {
    public static void main (String [] args) throws IOException
    {
    System.out.println ("Server starting ...\n");
    // Create a datagram socket bound to port 10000. Datagram
    // packets sent from client programs arrive at this port.
    DatagramSocket s = new DatagramSocket ();
    // Create a byte array to hold data contents of datagram packet.
    byte [] data = new byte [1450];
    // Create a DatagramPacket object that encapsulates a reference
    // to the byte array and destination address information. The
    // DatagramPacket object is not initialized to an address
    // because it obtains that address from the client program.
    DatagramPacket dgp = new DatagramPacket (data, data.length);
    // Enter an infinite loop. Press Ctrl+C to terminate program.

    FileOutputStream fout1;
    BufferedWriter out = new BufferedWriter(new FileWriter("output.txt"));
    BufferedWriter out1 =null;
    while (true)
    {
    // Receive a datagram packet from the client program.
    try
    {
    out1=new BufferedWriter(new FileWriter("output.txt",true));
    s.receive (dgp); // Display contents of datagram packet.
    System.out.println (new String(data));
    out1.write(new String (dgp.getData ()));
    out1.close();

    }
    catch(Exception ex)
    {
    out1.close();
    s.close();
    out1.close();
    System.exit(-1);
    }

    // Echo datagram packet back to client program.
    //s.send (dgp);
    }



    }
    }

    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import javax.swing.filechooser.*;
    import java.net.*;
    public class Client extends JFrame implements ActionListener
    {
    static private final String newline = "\n";
    JButton browse, loopback;
    JLabel input;
    JTextField text;
    JFileChooser fc;
    File file;
    JFrame JFParentFrame;

    JLabel ip;
    JLabel port,mac,mac1;
    JTextField ip1,port1;

    int ips;


    void std()throws IOException
    {

    String host = ip1.getText();
    System.out.println(host);

    String ipd=port1.getText();

    ips=Integer.parseInt(ipd);
    System.out.println(ips);


    // If user specifies a command-line argument, that argument
    // represents the host name.

    // if (args.length == 1)
    // host = args [0];

    DatagramSocket s = null;
    BufferedWriter out1=null;
    BufferedReader in =null;
    try
    {

    out1=new BufferedWriter(new FileWriter("abcd1.txt"));;
    // Create a datagram socket bound to an arbitrary port.
    s = new DatagramSocket ();
    // Create a byte array that will hold the data portion of a
    // datagram packet's message. That message originates as a
    // String object, which gets converted to a sequence of
    // bytes when String's getBytes() method is called. The
    // conversion uses the platform's default character set.
    // File file= new File("input.txt");
    in = new BufferedReader(new FileReader(file));
    DatagramPacket dgp;
    // out1 =


    int kz=0;
    long size=(int)file.length();
    System.out.println(size);
    byte [] buffer;
    char []buffer1=new char[1450];
    String buffer2;


    // buffer = new String ("Send me a datagram").getBytes ();
    // Convert the name of the host to an InetAddress object.
    // That object contains the IP address of the host and is
    // used by DatagramPacket.
    InetAddress ia = InetAddress.getByName (host);
    // Create a DatagramPacket object that encapsulates a
    // reference to the byte array and destination address
    // information. The destination address consists of the
    // host's IP address (as stored in the InetAddress object)
    // and port number 10000 -- the port on which the server
    // program listens.
    // FileOutputStream fout1;
    // BufferedWriter out1 = new BufferedWriter(new FileWriter("output.txt"));

    while(true)
    {
    if(kz<(size-1450))
    {
    kz=kz+1450;
    }
    else
    break;
    System.out.println("************"+size+"********** *"+kz+"**********");
    in.read(buffer1,0,1450);
    buffer2=new String(buffer1);
    out1.write(buffer2);
    System.out.println (buffer2);
    buffer=buffer2.getBytes();

    dgp = new DatagramPacket (buffer, buffer.length, ia,ips);
    s.send (dgp);
    for(long i1=0;i1<999999;i1++);



    }

    int remain=(int)(size-kz);
    int hell=remain+kz-1450;


    byte [] rbuffer;
    char []rbuffer1=new char[remain];
    String rbuffer2;


    System.out.println("************size= "+ size +"***********remain= "+remain+"**********"+hell+"****");


    in.read(rbuffer1,0,remain);
    rbuffer2=new String(rbuffer1);
    System.out.println ("*** "+rbuffer2+" ***");
    out1.write(rbuffer2);

    rbuffer=rbuffer2.getBytes();
    dgp = new DatagramPacket (rbuffer, rbuffer.length, ia,ips);
    s.send (dgp);
    in.close();
    out1.close();


    }
    catch (Exception e)
    {
    System.out.println (e.toString ());
    out1.close();



    }
    finally
    {
    if (s != null)
    s.close ();

    }

    }

    public Client(int i)
    {
    // getContentPane().setLayout();
    setTitle("SERVER/Client Loopback");

    ip=new JLabel("<html><font size=4 >Enter I.P. Address :</font></html>",null,JLabel.RIGHT);
    ip.setForeground(Color.black);


    mac=new JLabel("<html><font size=4 >MAC Address :</font></html>",null,JLabel.RIGHT);
    mac.setForeground(Color.black);

    mac1=new JLabel("<html><font size=4 >00-00-00-00-00-00 </font></html>",null,JLabel.RIGHT);
    mac1.setForeground(Color.black);

    JLabel sd=new JLabel("");
    JLabel sd1=new JLabel("");
    JLabel sd2=new JLabel("");
    JLabel sd3=new JLabel("");

    JLabel sd4=new JLabel("");


    port=new JLabel("<html><font size=4 >Enter Port id :</font></html>",null,JLabel.RIGHT);
    port.setForeground(Color.black);

    input=new JLabel("<html><font size=4 >Enter Input File :</font></html>",null,JLabel.RIGHT);
    input.setForeground(Color.black);


    text=new JTextField (10);
    text.setFont(new Font("Dialog", Font.PLAIN, 14));
    text.setForeground(new Color(0,0,0));

    ip1=new JTextField (10);
    ip1.setFont(new Font("Dialog", Font.PLAIN, 14));
    ip1.setForeground(new Color(0,0,0));

    port1=new JTextField (10);
    port1.setFont(new Font("Dialog", Font.PLAIN, 14));
    port1.setForeground(new Color(0,0,0));



    fc = new JFileChooser();

    browse = new JButton("Browse");
    browse.addActionListener(this);
    loopback=new JButton("Loopback");
    loopback.addActionListener(this);

    JPanel buttonPanel = new JPanel(new GridLayout(5,3,10,10)); //use FlowLayout
    buttonPanel.add(input);
    buttonPanel.add(text);
    // new GridLayout(4,1,10,10)
    buttonPanel.add(browse);

    buttonPanel.add(mac);
    buttonPanel.add(mac1);
    buttonPanel.add(sd4);



    buttonPanel.add(ip);
    buttonPanel.add(ip1);
    buttonPanel.add(sd);


    buttonPanel.add(port);
    buttonPanel.add(port1);
    buttonPanel.add(sd1);

    buttonPanel.add(sd2);


    buttonPanel.add(loopback);

    buttonPanel.add(sd3);

    getContentPane().add(buttonPanel);


    setSize(550,400);
    pack();
    setVisible(true);
    }

    public void actionPerformed(ActionEvent e)
    {
    //Handle open button action.
    if (e.getSource() == browse)
    {
    int returnVal = fc.showOpenDialog(Client.this);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    {
    file = fc.getSelectedFile();

    text.setText(file.getName());


    }
    else
    {

    }


    }


    if(e.getSource()==loopback)
    {
    try
    {
    std();
    }
    catch(IOException ex)
    {
    }
    }
    }



    public static void main(String[] args)
    {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    {
    public void run()
    {
    // createAndShowGUI();

    new Client(1);
    }
    });
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Exception in thread"main java.lang.Error:Unresolved compilation problem:at client

    rakshitha likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    rakshitha is offline Member
    Join Date
    Apr 2015
    Posts
    2
    Rep Power
    0

    Default Re: Exception in thread"main java.lang.Error:Unresolved compilation problem:at client

    i didnt get it

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: Exception in thread"main java.lang.Error:Unresolved compilation problem:at client

    Edit your post and put [code] at the start and [/code] at the end. Make sure the indentation is correct.

    The runtime exception is saying that your code has not compiled correctly. Compile the code before you attempt to run it. If there are compiler messages that you don't understand, copy and post them

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Exception in thread"main java.lang.Error:Unresolved compilation problem:at client

    Quote Originally Posted by rakshitha View Post
    i didnt get it
    Then why did you "like" it?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 1
    Last Post: 11-06-2011, 04:41 PM
  2. Replies: 2
    Last Post: 11-06-2011, 04:40 PM
  3. Replies: 6
    Last Post: 12-04-2010, 08:36 AM
  4. Replies: 1
    Last Post: 04-02-2009, 09:50 PM
  5. Replies: 6
    Last Post: 08-18-2008, 06:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •