Sending one image works, but when i repeat the cycle again it just doesn't work.
my Client side code (excerpt):
for(int i=0;i<50;i++){//fromServer.contains("image")
img = ImageIO.read(in);
System.out.println("Got image.");
label = new JLabel(new ImageIcon(img));
scrollPane.setViewportView(label);
fromServer = reader.readLine();
}
On the client side i have this output
Got image.
Got image.
Exception in thread "Thread-2" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:190)
at screenviewer.DataReciever.run(DataReciever.java:84)
my Server side code (excerpt):
dim = toolkit.getScreenSize();
System.out.println("Got screen size:" + dim.width + "x" + dim.height);
captureSize = new Rectangle(dim);
for (int i = 0; i < 50; i++) {
bufferedImage = robot.createScreenCapture(captureSize);
ImageIO.write(bufferedImage, "JPG", out);
System.out.println("Sent image!");
//out.flush(); this didn't helped
}
Please help this is for my "end of the year thesis". I need to finish my project fast.