Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Norm

Thread: javac:file not found: HelloWorld.java

  1. #1
    Brillyx is offline Member
    Join Date
    Sep 2014
    Posts
    7
    Rep Power
    0

    Question javac:file not found: HelloWorld.java

    Java noob here, title pretty much says it all. I put in the path so that javac could be recognized by the cmd prompt, which is a good start, but now I cannot get the cmd prompt to find and compile HelloWorld.java. It is probably something to do with my environment variables, because I had to add a path in order for "javac" to register in the cmd prompt.

    I'm sure this is a really novice mistake, can anyone help me?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: javac:file not found: HelloWorld.java

    Are you in the folder that contains the HelloWorld.java file when you issue the javac command?
    The javac command expects the file to be in the current folder. You may have to use the CD (change directory) command to move to the folder holding the file. Note: I use folder and directory as the same thing.

    Can you copy the full contents of the command prompt window and paste it here?
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Brillyx is offline Member
    Join Date
    Sep 2014
    Posts
    7
    Rep Power
    0

    Default Re: javac:file not found: HelloWorld.java

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Graham>javac
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are u
    sed
    -classpath <path> Specify where to find user class files and annotati
    on processors
    -cp <path> Specify where to find user class files and annotati
    on processors
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -proc:{none,only} Control whether annotation processing and/or compil
    ation is done.
    -processor <class1>[,<class2>,<class3>...] Names of the annotation processors
    to run; bypasses default discovery process
    -processorpath <path> Specify where to find annotation processors
    -d <directory> Specify where to place generated class files
    -s <directory> Specify where to place generated source files
    -implicit:{none,class} Specify whether or not to generate class files for
    implicitly referenced files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release

    -target <release> Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -Akey[=value] Options to pass to annotation processors
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system
    -Werror Terminate compilation if warnings occur
    @<filename> Read options and filenames from file


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

    Basically what I did here was: asked command prompt to find javac. Which it did.

    Then, asked it to find javac HelloWorld.java, which it did not do.

    I moved HelloWorld.java into the bin folder in C:\Program Files\Java\jdk1.7.0_67\bin like you said, and it still isn't working.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: javac:file not found: HelloWorld.java

    C:\Users\Graham>javac HelloWorld.java
    The javac program is looking in the Graham folder for the HelloWorld.java file.
    Where is the file located? Can it be moved to the Graham folder?
    Or can you use the CD command to move the command prompt window to the folder that has the file?

    Use the dir command to see what is in the current folder.

    I moved HelloWorld.java into the bin folder
    You should not put your files in the bin folder.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Brillyx is offline Member
    Join Date
    Sep 2014
    Posts
    7
    Rep Power
    0

    Default Re: javac:file not found: HelloWorld.java

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Graham>cd Desktop

    C:\Users\Graham\Desktop>java HelloWorld
    Hello, World

    C:\Users\Graham\Desktop>

    Got it. I know what my problem was. My directory wasn't correct, so it was looking for the file in the wrong directory. This is my very first programming attempt, so I didn't realize it had to be pinpoint exact.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: javac:file not found: HelloWorld.java

    had to be pinpoint exact.
    Yes, that's how computers work. That's what we rely on when we use them.
    gimbal2 likes this.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: javac:file not found: HelloWorld.java

    Quote Originally Posted by Brillyx View Post
    ... so it was looking for the file in the wrong directory.
    Slightly pedantic correction here, but javac was looking for the file in the correct directory (ie the directory you asked it to look in)...it's just the file wasn't there.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Compiling HelloWorld and Error with java and javac
    By daveabes in forum New To Java
    Replies: 8
    Last Post: 02-18-2014, 02:22 PM
  2. Replies: 7
    Last Post: 08-29-2011, 07:35 PM
  3. javac: file not found:
    By Tastosis in forum New To Java
    Replies: 6
    Last Post: 03-24-2011, 06:35 AM
  4. Javac, file not found
    By Zorobay in forum New To Java
    Replies: 1
    Last Post: 02-15-2010, 12:30 PM
  5. javac:file not found
    By lovearora in forum New To Java
    Replies: 3
    Last Post: 02-09-2009, 04:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •