Guest User

Untitled

a guest
May 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. public class DTO implements Serializable{
  2. private static final long serialVersionUID = 1L;
  3. private String name;
  4.  
  5. public DTO()
  6. {
  7. this.name = "name";
  8. }
  9.  
  10. public String getName() {
  11. return name;
  12. }
  13.  
  14. @Override
  15. public int hashCode() {}
  16.  
  17. @Override
  18. public boolean equals(Object obj) {}
  19.  
  20. public class Parent {
  21.  
  22. public static void main(String[] args) {
  23.  
  24. try {
  25. new Parent().start();
  26. } catch (Exception e) {
  27. e.printStackTrace();
  28. }
  29. }
  30.  
  31. public void start() throws IOException, InterruptedException, ClassNotFoundException
  32. {
  33. String classpath = System.getProperty("java.class.path");
  34. String className = Child.class.getCanonicalName();
  35.  
  36. ProcessBuilder builder = new ProcessBuilder(
  37. "java", "-cp", classpath, className);
  38.  
  39. Process process = builder.start();
  40.  
  41. if (process.isAlive()) {
  42.  
  43. ObjectInputStream input = new ObjectInputStream(process.getInputStream());
  44. DTO dto = (DTO)input.readObject();
  45.  
  46. }
  47. }
  48. }
  49.  
  50. public class Child {
  51.  
  52. public static void main(String[] args) throws IOException {
  53. DTO dto = new DTO();
  54.  
  55. System.out.println("printing random text here");
  56.  
  57. ObjectOutputStream stream = new ObjectOutputStream(System.out);
  58. stream.writeObject(dto);
  59. stream.flush();
  60. stream.close();
  61. }
  62. }
  63.  
  64. java.io.StreamCorruptedException: invalid stream header: 64617364
  65. at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
  66. at java.io.ObjectInputStream.<init>(Unknown Source)
  67. at working.Parent.start(Parent.java:35)
  68. at working.Parent.main(Parent.java:14)
Add Comment
Please, Sign In to add comment