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 Basics Getting Started with Java Receiving Input

When I make a new file in Java, it wont comply

When I do javac (my file name) java1.java ,it wont comply. This is what I get this-

treehouse:~/workspace$ javac Java1.java
Java1.java:3: error: class Introductions is public, should be declared in a file named Introductions.java
public class Introductions {
^
1 error

1 Answer

Brandon Zeck
Brandon Zeck
3,127 Points

<p\>Tegh Mehta, <p>Please rename your java file to Introductions.java.</p><p> That is what the error says too, once you take a look at it.</p><p> In java, the file has to be given the name of the class that it contains.</p><p> So, you can either rename the file to Introductions.java OR rename the class and its constructors,if any, to Java1.</p><p> Hope this helps.</p><p> Please Up vote and Mark as Answer if it helps. And in case, it does not, please reply so that we will get to know.</p> <p> Thanks.</p>

Ok thanks anyways. I just started and I didn't know but I figured it out the next day. Thanks for your help.