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 trialjordanbruner
10,055 Pointsjavac can't find file
I'm trying to compile the exact code given in the workspace but for some reason it says javac cannot find the file I am trying to compile (Example.java). I am 100% sure Example.java is saved and the orange dot is gone at the top of the file name in Workspace. Is there any reason this error might be appearing?
4 Answers
Kristian Terziev
28,449 PointsGive us the line you're trying to run in the console. Also, make sure you're not in the repl. And please include the error that it gives you. Thanks
jordanbruner
10,055 PointsMy command-line is a simple javac Example.java.If I do something like javac Example.java && java Example or clear && ... the same problem still occurs. I am sure I am not in repl. The error says "javac: file not found: Example.java" "Usage: javac <options> <source files>" "use -help for a list of possible options". Typing in "help" just opens a big options menu that doesn't clarify anything.
Craig Dennis
Treehouse TeacherHow about doing an ls
in the terminal.
Craig Dennis
Treehouse TeacherStill stuck Jordan?
jordanbruner
10,055 PointsHey Craig,
I just did this and when I typed "ls" the only option is "com". I understand this means that the file is not showing up in the directory properly but I still don't understand why...
Craig Dennis
Treehouse TeacherWhy don't you fork your workspace and share it here. We'll figure it out. Sometimes things get dropped in the wrong place using the Folders UI in the editor.
Michael Van Dusen
12,136 PointsSame problem here. Typing ls shows com only. I have deleted workspace and re-written twice, closed browser re-written, moved files. Nothing works. Please fix this ASAP, its hard to proceed with course when you cant run the program and follow along!
Craig Dennis
Treehouse TeacherCan you fork your workspace please?
Michael Van Dusen
12,136 PointsWorkspace forked is that all you need or can I add it here? I dont see any way to push it!
Craig Dennis
Treehouse TeacherDoh! Sorry I used the wrong term. Snapshot and share the link here.
Michael Van Dusen
12,136 PointsCraig Dennis
Treehouse TeacherIf you look at that snapshot you'll see that your Example.java is in your com folder. You can move it using this command:
mv com/Example.java Example.java
I ran it and your code worked!
Michael Van Dusen
12,136 PointsGreat the move command worked. Problem is all this time I thought Example.java was supposed to be in com folder. This is probably just a coincidence in the video but I think it may be whats leading others to make this same mistake. In the video when you explain that we want to create the Example.java file in the default package at about 2:16 or 2:17 into the video your cursor moves to the com folder and then the dialog box to create new file pops up. So I inferred from listening and following your cursor on the screen that you were saying that the com folder was where the file belonged. That it was the "default" location! Thank you for your quick response in helping me to correct my mistake! Really enjoying the class so far!