I'm programing client (android) server (java) application. In both client and server I'm using some classes that I create in third project and imported it as .jar file. When I'm running server side from eclipse everything works fine, but if I run .class files from terminal with (java className &) I'm starting to get
java.io.StreamCorruptedException: invalid type code: 2E
when server should read object that is imported from .jar file.
Code that read comming data on server side:
try (
ObjectOutputStream outToClient = new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream inFromClient = new ObjectInputStream(socket.getInputStream());
) {
String inputLine, outputLine;
checkClientStatus(outToClient);
Object p;
for(;;) {
p = inFromClient.readObject();
if(p instanceof String){
String s = (String) p;
if(s.equals("pong")) {
isClientAlive = true;
System.out.println("pong");
}else{
System.out.println("You said:"+s);
outToClient.writeObject("You said:"+s);
}
}else if(p instanceof Position){
System.out.println("pozicija");
}
}
}catch (SocketTimeoutException exc){
// you got the timeout
}catch (EOFException exc){
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
// end of stream
}catch (IOException exc){
// some other I/O error: print it, log it, etc.
exc.printStackTrace(); // for example
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
I'm assuming that binary files aren't builded correct or something?