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 - Retired Efficiency! Menu UI

Kshatriiya .
Kshatriiya .
1,464 Points

javac: file not found

Hello I can't run any java file with the javac command, it keeps giving me the file not found error.

I've checked the spelling, make sure the letters are case correct and everything, I can't even run a simple javac Song.java.

here is a snapshot of my work space.

http://w.trhou.se/bk5rmtn7vl

Please take a look, thank you.

Edit: for some reason, refreshing the folder doesn't create the class files automatically, maybe this is what's causing the issue?

5 Answers

You still miss one parenthesis for the Class in Karaoke.java.

make sure you have the parenthesis for the main method and class, It means, you should see two parenthesis on the bottom lines.

Kshatriiya .
Kshatriiya .
1,464 Points

fixed that returning the same error:

   javac: file not found: Karaoke.java                                                                                                                         
   Usage: javac <options> <source files>                                                                                                                       
   use -help for a list of possible options  

ran the same command on Song, KaraokeMachine etc the same error:

   javac: file not found: KaraokeMachine.java                                                                                                                  
  Usage: javac <options> <source files>                                                                                                                       
   use -help for a list of possible options

Hi Kshatriiya,

In the workspace snapshot that you included in your original post, your "Karaoke.java" file is saved inside the "com" folder. That is why the compiler can't find it. Move it up to the main "Java Data Structures - Map Out the MVP" folder.

I forked your worskspace and was able to compile the code by making this change (and adding the closing curly brace suggested by jungkeekim): https://w.trhou.se/paayzlzq7o.

It's always the best to practice and test on your local computer. As you said, it can be the problem caused by the cache on your browser or the server itself. Don't waste too much time to figure it out while learning Java.

If you are using Window, I can tell you how you can test your java program with the console or if you like IDE, you can use the eclipse.

If you have any further question, Please ask me.

Kshatriiya .
Kshatriiya .
1,464 Points

I copied and pasted the same code to a different work space and it works fine, I ran the code in BlueJ and it worked fine. I think there is an issue with the particular work space.

Could the missing .class files have something to do with it?

As I tested your codes in my IDE, you made two mistakes in Karaoke.java.

  1. you missed parenthese for the main method.
  2. you missed package name

These is the fixed version

package com; <---this

import com.teamtreehouse.model.Song; import com.teamtreehouse.model.SongBook; import com.teamtreehouse.KaraokeMachine;

public class Karaoke {

public static void main(String[] args) {


SongBook songBook = new SongBook();
KaraokeMachine machine = new KaraokeMachine(songBook);
machine.run();
} <---this

}

a

Kshatriiya .
Kshatriiya .
1,464 Points

I did have the parenthesis and I added package.com now but still returning the same error. I copied and pasted the same code in a new workspace and it works fine though.

It's not "package.com;", it's "package com;". Get rid of the period between package and com.

If you still have the problem, please post your Karaoke.java.

Kshatriiya .
Kshatriiya .
1,464 Points

Hi, here is the whole project file

https://www.dropbox.com/s/i0zm5sa6cdoloxe/project%20%281%29.zip?dl=0

I've changed the package details, but it is odd that i can't even javac execute other java files, not just the Karaoke.