Page 1 of 2 12 LastLast
Results 1 to 20 of 29
Like Tree2Likes

Thread: javac is not recognized as an internal or external command error

  1. #1
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default javac is not recognized as an internal or external command error

    I installed jdk and wrote my first program on notepad. When I try to compile with command "javac *.java" it shows "javac is not recognized as an ..........."
    Then after reading some threads, I changed the path in Environment Variables, now it shows

    Javac : file not found : *.java
    usage : javac <options> <source file>
    use - help for a list of possible options.

    So I don't know where I'm wrong now. Where should I save *.java file?

    Thanks in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default

    The OS can not find the javac command. You need to add the path to the folder containing the javac.exe file to the PATH environment variable.
    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and
    Click on the Environment variable's button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Add the new path using ; to separate it
    Its a stupid small text field so be careful.
    sunde887 likes this.

  3. #3
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default

    Thanks. So after I set the variable can I save *.java file anywhere in my computer? Or it should be in some particular folders?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,999
    Blog Entries
    7
    Rep Power
    19

    Default

    Quote Originally Posted by learning_grjava View Post
    I installed jdk and wrote my first program on notepad. When I try to compile with command "javac *.java" it shows "javac is not recognized as an ..........."
    Then after reading some threads, I changed the path in Environment Variables, now it shows

    Javac : file not found : *.java
    usage : javac <options> <source file>
    use - help for a list of possible options.

    So I don't know where I'm wrong now. Where should I save *.java file?

    Thanks in advance
    There is no .java file in the directory from where you started javac. Your path variable is set correctly (otherwise the OS couldn't have found the javac.exe file). Change your directory to where your .java file is stored and try again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    If you don't know how to navigate on command line, use cd to move to the right directory(where the file is located), and then try executing
    Java Code:
    javac -cp . *.java

  6. #6
    AUSTINDAN is offline Member
    Join Date
    Aug 2011
    Posts
    1
    Rep Power
    0

    Default i am getting this error pls help

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\MAHE>javac
    'javac' is not recognized as an internal or external command,
    operable program or batch file.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default

    Did you miss this post in #2 ???

    The OS can not find the javac command. You need to add the path to the folder containing the javac.exe file to the PATH environment variable.
    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and
    Click on the Environment variable's button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Add the new path using ; to separate it
    Its a stupid small text field so be careful.

  8. #8
    Fisty's Avatar
    Fisty is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    So I entered into the System Variables ;C:\Program Files\Java\jdk7.0_03\bin\javac

    and it still gives me the same answer when I am trying to convert java into a class file
    what have I done wrong?

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: javac is not recognized as an internal or external command error

    Quote Originally Posted by Fisty View Post
    So I entered into the System Variables ;C:\Program Files\Java\jdk7.0_03\bin\javac

    and it still gives me the same answer when I am trying to convert java into a class file
    what have I done wrong?
    Which system variable?

    If you can't express yourself clearly and just post vague reports of your actions, it's not going to be possible for anyone here to help you.

    Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)

    db
    Last edited by DarrylBurke; 03-17-2012 at 06:58 AM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default Re: javac is not recognized as an internal or external command error

    Did you read this:
    You need to add the path to the folder containing the javac.exe file to the PATH environment variable.

    You said you added:
    ;C:\Program Files\Java\jdk7.0_03\bin\javac

    Is javac the folder containing the javac.exe file?

  11. #11
    Arcanexanth is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    So I'm having the exact same problem and I've triple checked everything.

    Java_Home: E:\Program Files\Java\jdk1.7.0_03\bin
    Path: ;%Java_Home%;

    Computer will not see javac unless I'm in it's folder but I can't run my project from there.

    Also tried path: ;%Java_Home%\bin;

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default Re: javac is not recognized as an internal or external command error

    Open a command prompt window and enter: Path
    copy the contents 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.

  13. #13
    Arcanexanth is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    I reinstalled JDK and that fixed it. But now after I ran javac and the program it made a class and I run that and it doesn't return with passed arguments, I'm new to java, yet when I run it with Netbeans it works.

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default Re: javac is not recognized as an internal or external command error

    Post the console that shows the problem. Add comments to the post saying what the problem is.
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    Arcanexanth is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    E:\Users\George\Documents\NetBeansProjects\DumpArg s\src\dumpargs>java DumpArgs
    Exception in thread "main" java.lang.NoClassDefFoundError: DumpArgs (wrong name:
    dumpargs/DumpArgs)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unkno wn Source)

    I type java DumpArgs and it gives me that ^

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default Re: javac is not recognized as an internal or external command error

    DumpArgs (wrong name: dumpargs/DumpArgs)
    You have a package statement putting the class in a package: dumpargs
    Remove that or change how you use the java command to use the package name with class name.
    java dumpargs.DumpArgs
    from the folder that contains the dumpargs folder
    If you don't understand my response, don't ignore it, ask a question.

  17. #17
    Arcanexanth is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    Netbeans automatically put it in a package, how do I stop it from doing that?

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default Re: javac is not recognized as an internal or external command error

    Sorry, I don't use your IDE.
    If you don't understand my response, don't ignore it, ask a question.

  19. #19
    Arcanexanth is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: javac is not recognized as an internal or external command error

    Ok well, thank you anyways, I'll figure something out now.

    Ok so I just put in a text program and saved as .java since I'm learning Java at this point.
    Last edited by Arcanexanth; 04-25-2012 at 04:07 AM.

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: javac is not recognized as an internal or external command error

    That's the best way.
    Or you could use Notepad++ (google for it) which is a text editor, but it does code highlighting for you making it slightly easier to see what you;re doing.
    You still need the command line to compile.
    Please do not ask for code as refusal often offends.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 25
    Last Post: 06-23-2012, 11:30 AM
  2. Replies: 19
    Last Post: 11-27-2010, 12:31 AM
  3. Replies: 28
    Last Post: 10-26-2010, 04:39 AM
  4. Replies: 13
    Last Post: 09-17-2009, 07:56 AM
  5. 'javac' is not recognized as an internal or external command
    By sam_1032002@btopenworld.c in forum New To Java
    Replies: 3
    Last Post: 10-18-2008, 02:40 AM

Posting Permissions

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