Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Carl Johnson
Carl Johnson
1,232 Points

I got a bunch of errors, wich i am not able to fix

So i watched the video on serialization. I wrote the same code as the instructor/tutor, but i got a bunch of error-messages and wasnt able to compile. Here is my Treets.java:

package com.teamtreehouse;
import java.io.*;

public class Treets {

  public static void save(Treet[] treets){
    try (
      FileOutputStream fos = new FileOutputStream("treets.ser");
      ObjectOutputStream oos = new ObjectOutputStream(fos);
    ) {
      oos.writeObject(treets);
    } catch(IOException ioe) {
      System.out.println("Problem saving Treets");
      ioe.printStackTrace();
    }
  }
}

My Errors: Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
./com/teamtreehouse/Treets.java:8: error: <identifier> expected
public void static save(Treet[] treets){
^
./com/teamtreehouse/Treets.java:8: error: '(' expected
public void static save(Treet[] treets){
^
./com/teamtreehouse/Treets.java:8: error: invalid method declaration; return type required
public void static save(Treet[] treets){
^
./com/teamtreehouse/Treets.java:23: error: class, interface, or enum expected
}

I don't even get the first error-message. I am sitting here really frustrated...

Can you post a link to the course and also share your workspace link?

Steve.

4 Answers

Carl Johnson
Carl Johnson
1,232 Points

For sure:

Link to the video: https://teamtreehouse.com/library/serialization

Link to the Workspace (hope it works): https://w.trhou.se/cw43w9tssi

thanks a lot for your efford :)

Workspace didn't work. Click the icon top-right that looks like a briefcase with a dot on it. (It's a camera!) That'll open a new window - share that link.

Carl Johnson
Carl Johnson
1,232 Points

Hey,

sorry, i am new on teamtreehouse. I hope this link will work: https://w.trhou.se/cw43w9tssi

kind regards,

carl

Carl Johnson
Carl Johnson
1,232 Points

Yeah, now after reloading the whole workspace i did not get any errors. Maybe the workspace was buggy. Thanks for the efford. I try to do the whole video again.

All works fine here too.

Good luck with the rest of the course.

Steve.

OK - I've got your code. What did you run to generate the errors? I did javac Example.java && java Example and this worked fine.

What did you try?

Steve.