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 Meet Objects Creating Classes

Domagoj Varovic
Domagoj Varovic
354 Points

Main method not found in class PezDispencer, please define the main method as:

this is the error i keep getting. I did everything Craig was doing in the video but I keep getting error that the main method is not found. Is it because i did something wrong with making new PezDispencer.java in folder under Example.java?

Can you share your Workspace so we can see your code, please?

Steve.

Domagoj Varovic
Domagoj Varovic
354 Points

i found out what i was doing wrong. In console i tried to load the wrong file ( I was entering PezDispenser.java, while I should enter Example.java). But now when i managet do do that correctly i keep on geeting this error: location: class Example
Example.java:4: error: cannot find symbol
PezDispenser dispenser = new PezDispenser();
^
symbol: class PezDispenser
location: class Example
2 errors

BTW how to share my workspace so you can see?

2 Answers

Hi there,

If the error is 'cannot find symbol' you are using a variable name that is not declared properly; probably just a spelling error.

To share the workspace, click the camera icon towards the top-right (it's the left-most of the three icons) and take a snapshot. Share the URL that it generates.

Steve.

Domagoj Varovic
Domagoj Varovic
354 Points

Here is my workshop. https://w.trhou.se/ixtfrr8p8c Steve, thanks for helping!

If you change the file name from PezDispencer.java to PezDispenser.java, it will work fine. Chance the c to an s.

Steve.

Domagoj Varovic
Domagoj Varovic
354 Points

Thank you Steve u helped a lot! :)

:+1: :+1: