Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Efficiency! Implement Chooser UI

israel meza
PLUS
israel meza
Courses Plus Student 10,890 Points

file wont compile or run

All of a sudden it seems like the worspace/terminal cant find my files. When try Javac KaraokeMachine.java from worksce dir it says:
javac: file not found: KaraokeMachine.java
Usage: javac <options> <source files> . i then tried switching directory and try to compile. But it cant find the other classes/files(SongBook and Song) . It shows errors every where i used the class.

3 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,161 Points

Please make a snapshot of your workspace, and share a link here

Here is the video how to do it

https://teamtreehouse.com/library/previews-and-snapshots

About the problem

You should see files on the left side of workspace, do you see them ?

Please run ls command

In the console write ls command. This command lists all available files in directory

The fastest way

But the fastest way is to make a snapshot and share a link here

israel meza
PLUS
israel meza
Courses Plus Student 10,890 Points

The problem goes away on its on if I close and restart the worspace. https://w.trhou.se/7ri0n5npk2

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,161 Points

Ok. So let me try to explain how it works.

Easy and proper way

As you can see Craig in his videos compiles only Karaoke.java file, i.e. we don't need to care about all other classes as long as we have compile one that runs everything:

treehouse:~/workspace$ javac Karaoke.java

Compiler checks for all import statements for example com.teamtreehouse.KaraokeMachine, and then on his own find and compiles file KaraokeMachine.java that MUST lie in com/teamtreehouse directory.

The same with other classes.

Now if you really want to compile ONLY one class

You can compile your App class by class. For whatever reason you want to do it I don't know. But Ok I can tell you how. Although I suggest do things like Craig does...

OK.

If you want to compile ONLY KaraokeMachine.java in Treehouse Workspaces, you have to type the following:

treehouse:~/workspace$ javac com/teamtreehouse/KaraokeMachine.java

Analogously works for Song and SongBook.java

Coming back to your original question

Why do you need at all to compile KaraokeMachine and not Karaoke like Craig does ?