Error in Javax.Swing.ImageIcon
Hi To All!:(handshake):
My self Raj, I need your help for run my program,
By using Server Socket & Socket run the program to monitoring the clients from server
If i run the program in single system, it run perfectly and give desired out put also,
But!
if i using different system it client get connect and immediately if get disconnect automatically, it show an error like
Server Side:
"run:
New client Connected to the server
java.io.InvalidClassException: javax.swing.ImageIcon; local class incompatible: stream classdesc serialVersionUID = 532615968316031794, local class serialVersionUID = -962022720109015502
at java.io.ObjectStreamClass.initNonProxy(ObjectStrea mClass.java:579)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectI nputStream.java:1601)
at java.io.ObjectInputStream.readClassDesc(ObjectInpu tStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:369)
at remoteserver.ClientScreenReciever.run(ClientScreen Reciever.java:33)
"
Client side:
"run:
Connecting to server ..........
Connection Established.
Preparing InputStream
Waiting for command
before sending image"
My coding is
"
package remoteserver;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
class ClientScreenReciever extends Thread {
private ObjectInputStream cObjectInputStream = null;
private JPanel cPanel = null;
private boolean continueLoop = true;
public ClientScreenReciever(ObjectInputStream ois, JPanel p) {
cObjectInputStream = ois;
cPanel = p;
//start the thread and thus call the run method
start();
}
public void run(){
try {
//Read screenshots of the client then draw them
while(continueLoop){
//Recieve client screenshot and resize it to the current panel size
ImageIcon imageIcon = (ImageIcon) cObjectInputStream.readObject();
System.out.println("New image recieved");
Image image = imageIcon.getImage();
image = image.getScaledInstance(cPanel.getWidth(),cPanel.g etHeight()
,Image.SCALE_FAST);
//Draw the recieved screenshot
Graphics graphics = cPanel.getGraphics();
graphics.drawImage(image, 0, 0, cPanel.getWidth(),cPanel.getHeight(),cPanel);
}
} catch (IOException ex) {
ex.printStackTrace();
} catch(ClassNotFoundException ex){
ex.printStackTrace();
}
JOptionPane.showMessageDialog(cPanel,"Client DISConnected");
}
}
"
Re: Error in Javax.Swing.ImageIcon
You're running different versions of the Java virtual machine. The serial ids of a built-in class differ (as the Exception message told you). Make your clients and server run the same Java version.
kind regards,
Jos
Re: Error in Javax.Swing.ImageIcon
Thank you Mr.jos!
i installed jdk.6 & 7 also in the both systems..,
running by using JDK.6 with netbeas IDE 6.9
what ca i do now..,
Re: Error in Javax.Swing.ImageIcon
I both your server and clients are running the same Java version, try to run your program again and see ... (make sure you recompile your program against that latest Java version).
kind regards,
Jos
Re: Error in Javax.Swing.ImageIcon
Thank you sir..,
i try now..,
Re: Error in Javax.Swing.ImageIcon
Thanks Mr.Jos!
it is running well sir..,
I am very Happy With You Mr.Jos..,
Thank to Jesus..,
Re: Error in Javax.Swing.ImageIcon
Good to read that it runs now; the error message was trying to tell you what was wrong: the serial version ids were different so there were two different versions of one and the same class; so your client(s) and server were running different versions of Java. Learning how to read error messages pays off ;-)
kind regards,
Jos
Re: Error in Javax.Swing.ImageIcon
I am happy with your idea sir..,
Have A Happy Day..,