• Post Reply Bookmark Topic Watch Topic
  • New Topic

Keep getting 'javac: file not found' on command line for hello world  RSS feed

 
Kyle Jones
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I trying to run a simple Hello World program from my command line. (using Terminal on Mac OSX) and i cant seem to figure where im going wrong

first i type in the directory: cd Documents/workspace/HelloWorld then javac HelloWorld.java

this is when i get the result:

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


Any help with this would be great. thanks in advance
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a file in that directory named "HelloWorld.java"?
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.java files may be located in src directory.

Please post an ls -l of your Documents/workspace/HelloWorld directory.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a file called HelloWorld.java inside Documents/workspace/HelloWorld?
Check this carefully. The file might be called HelloWorld.java.txt if you use Microsoft Notepad.
Try typing dir in console and post the output.


EDIT:
Oh sorry, I didn't notice that you are not using Windows.
 
Kyle Jones
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the responses

In the directory Documents/workspace/HelloWorld there are 2 folders (bin and src) inside bin folder has HelloWorld.class, and inside src folder has HelloWorld.java
 
Kyle Jones
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help ive figured it. Really simple i must of been typing scr instead of src . thanks
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out It is surprising how tiny spelling errors like that can cause no end of trouble, and they can be so difficult to see. Next time something like that happens, posting a copy‑and‑paste of the exact error/instruction/whatever may allow somebody else to find the spelling error.
 
Kyle Jones
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Well done sorting it out It is surprising how tiny spelling errors like that can cause no end of trouble, and they can be so difficult to see. Next time something like that happens, posting a copy‑and‑paste of the exact error/instruction/whatever may allow somebody else to find the spelling error.


Will keep that in mind. cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!