Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DTO implements Serializable{
- private static final long serialVersionUID = 1L;
- private String name;
- public DTO()
- {
- this.name = "name";
- }
- public String getName() {
- return name;
- }
- @Override
- public int hashCode() {}
- @Override
- public boolean equals(Object obj) {}
- public class Parent {
- public static void main(String[] args) {
- try {
- new Parent().start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void start() throws IOException, InterruptedException, ClassNotFoundException
- {
- String classpath = System.getProperty("java.class.path");
- String className = Child.class.getCanonicalName();
- ProcessBuilder builder = new ProcessBuilder(
- "java", "-cp", classpath, className);
- Process process = builder.start();
- if (process.isAlive()) {
- ObjectInputStream input = new ObjectInputStream(process.getInputStream());
- DTO dto = (DTO)input.readObject();
- }
- }
- }
- public class Child {
- public static void main(String[] args) throws IOException {
- DTO dto = new DTO();
- System.out.println("printing random text here");
- ObjectOutputStream stream = new ObjectOutputStream(System.out);
- stream.writeObject(dto);
- stream.flush();
- stream.close();
- }
- }
- java.io.StreamCorruptedException: invalid stream header: 64617364
- at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
- at java.io.ObjectInputStream.<init>(Unknown Source)
- at working.Parent.start(Parent.java:35)
- at working.Parent.main(Parent.java:14)
Add Comment
Please, Sign In to add comment