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 Introduction to Your Tools

Shailesh Gor
Shailesh Gor
2,975 Points

I have been trying to write first code and console said to me java is invalid flag.

I have been trying for last two hours but I couldn't get write . I typed in console. java Introduction. java and next I have gotten java is invalid flag. please help to solve this problem. Thanks.

2 Answers

Christopher Augg
Christopher Augg
21,223 Points

Hello Shailesh,

The error you are getting is because there is a space between Introduction. and java

However, you will get a "could not find or load" error if you use java Introduction.java because you need to use javac and the name of the java file is Introductions.java with an s.

When we compile with the javac command we write out the entire filename with its extension. However, when we run our compiled byte code with the java command, we do not include the extension.

treehouse:~/workspace$ javac Introductions.java                                                  
treehouse:~/workspace$ java Introductions                                                        
Hello, I am Chris   

I hope this helps.

Regards,

Chris

Shailesh Gor
Shailesh Gor
2,975 Points

Thanks for your help but it didn't work . I have been typing same code but it steel not work.

Christopher Augg
Christopher Augg
21,223 Points

Sorry to hear that. Can you please fork you workspace so I can take a look at it?

Regards,

Chris