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 Java Objects (Retired) Harnessing the Power of Objects Methods and Constants

Matthew Huber
PLUS
Matthew Huber
Courses Plus Student 879 Points

Why can't I load PezDispenser.java?

Every time I try loading PezDispenser.java, I get this error: java> load PezDispenser.java
ERROR: ';' expected
load PezDispenser.java;
^
ERROR: not a statement
load PezDispenser.java;
^

ERROR: ';' expected
load PezDispenser.java;
^
ERROR: not a statement
load PezDispenser.java;
^

1 Answer

Hi. I was getting the same as Matthew did to start with. I tried Mario's advice of attempting to compile the PezDispenser.java file by using javac PezDispenser.java then java PezDispenser - this failed to compile because no "main method" was defined.

I continued watching the video anyway and noticed that Craig typed :load PezDispnser.java further into the video - the first time I could have sworn that he just typed load (but no, I've double checked).

If you do type :load PezDispenser.java then sure enough you get the output:

Loaded source file from PezDispenser.java

No compiling required :)

CD Lim
CD Lim
4,782 Points

works for me... thanks