I have to pass an ArrayList over tcp socket (Server > Client) over the network. When I pass and Arraylist of Strings it works fine and the client is able accept the ArrayList and and print. but when the ArrayList is off Objects I have many exceptions and it does not work. Have a look below please.
Server
ArrayList<Database> List = new ArrayList<>(); //Database is a seperate class
Database item1 = new Database();
item1.code = "1568";
item1.name = "Round Table";
item1.details = "Ikeas best Seller";
item1.inStock = "17";
List.add(item1);
...
ObjectOutputStream oout = new ObjectOutputStream(socket.getOutputStream());
oout.writeObject(List);
Client
ObjectInputStream iin = new ObjectInputStream(socket.getInputStream());
Object items = iin.readObject();
Using this code I have many Exceptions thrown. If I replace the array with a string type array like ArrayList<String> Items = new ArrayList<>(); It will work fine. Any Ideas? I am really stack here. Thank You!
Databaseclass serializable? If not, you need to serialize it to send it.