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 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,175 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,175 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 ?