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 Local Development Environments Exploring Your IDE Creating Your First Project

Greg Wienecke
Greg Wienecke
20,765 Points

Error:(6, 8) java class Systemizer is public, should be declared in a file named Systemizer

When I try to run it I get this error. Error:(6, 8) java class Systemizer is public, should be declared in a file named Systemizer.

I named it Systemizer, and it says Main.java - Systemizer at the top just like Craig's.

I noticed that in the video Craig's says public class Main, but in the teacher's notes the code he has us copy/paste says public class Systemizer. I tried it both ways and get an error both times. Can anyone help? Here is my code that I copied and pasted from the teacher's notes:

package com.teamtreehouse;

import java.util.Set;
import java.util.TreeSet;

public class Systemizer {

    public static void main(String[] args) {
        System.out.printf("This is the classpath:  %s %n",
                System.getProperty("java.class.path"));
        Set<String> propNames = new TreeSet<String>(System.getProperties().stringPropertyNames());
        for (String propertyName : propNames) {
            System.out.printf("%s is %s %n",
                    propertyName,
                    System.getProperty(propertyName));
        }

    }
}
Aaron Kaye
Aaron Kaye
10,948 Points

What is the name of your file?

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

I know this is an old post, but there is a naming error in the code you copy from the Teacher's Notes.

Instead of public class Systemizer, which will cause that error. It should be public class Main which runs with no errors.

Just need a little fix up Craig Dennis :)

:dizzy:

Greg Wienecke
Greg Wienecke
20,765 Points

Thanks for the response Jason! I thought I had tried that already, but anyway it worked this time.

Greg Wienecke
Greg Wienecke
20,765 Points

The project is named Systemizer and the file is ~/IdeaProjects/Systemizer