Results 1 to 9 of 9
  1. #1
    ashin is offline Member
    Join Date
    Nov 2008
    Posts
    71
    Rep Power
    0

    Default javac is not recognized as internal or external command, operable program or batch...

    please help me guys to solve this... "javac is not recognized as internal or external command, operable program or batch file", im trying to code java in notepad and compile it through "cmd".... but this is the result everytime i type javac Filename.java..... :(

    and where i can find the j2sdk.... is it the same in jdk1.6.0_10???
    tnx....

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Smile classpath

    relax, this is all known issues.
    Quote Originally Posted by ashin View Post
    "javac is not recognized as internal or external command, operable program or batch file"
    Think of letters such as C:\Program Files or ~/developer/project as a way for the machine to find things. Okay, on my machine a program called javac.exe is in a location. That location is "C:\Program Files\Java\jdk1.5.0\bin\javac.exe"

    Find where yours is.

    Then make that the first part of your instructions to the machine, the command line.

    Then we have several switches and so on, which we will discuss but first we find the location of your code, easiest to do that is "File Save As..." on Windows. This is called a path. That is the next thing on the command line.
    Quote Originally Posted by ashin View Post
    I am trying to code java in notepad and compile it through "cmd".... but this is the result everytime i type javac Filename.java
    We can do this with batch files, replacing a rather nasty snag of trying to figure something called "CLASSPATH" which will often be the way people say to do it. There are several editors, many of them will do this classpath stuff for you. Better right now to do it manually so as to see what is going on.
    Quote Originally Posted by ashin View Post
    where i can find the j2sdk - is it the same in jdk1.6.0_10???
    Basically, yes. Java 2 is a naming convention decided by the sales department. Figure generally that that happend at jdk 1.2 and we are now up to 6 with 7 not too far away. For beginner work this is not much of an issue except for download times, I use jdk 5
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    ashin is offline Member
    Join Date
    Nov 2008
    Posts
    71
    Rep Power
    0

    Default

    sir.... ive done your instruction but it says that "the directory is invalid"....

    this is what ive done:
    1.type "cmd" in prompt
    2. C:\Documents and Settings\aShiniSha> cd C:\Program Files\Java\jdk1.6.0_10\bin\javac.exe
    3. after i typed the statement in no.2, the result says that "The directory name is invalid...

    my javac.exe is located at no.2 path...

    tnx sir

  4. #4
    J-Live is offline Member
    Join Date
    Oct 2008
    Posts
    24
    Rep Power
    0

    Default

    Update the PATH variable (Optional)

    You can run the JDK without setting the PATH variable, or you can optionally set it as a convenience.

    Should I set the PATH variable?
    Set the PATH variable if you want to be able to conveniently run the JDK executables (javac.exe, java.exe, javadoc.exe, etc.) from any directory without having to type the full path of the command. If you don't set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

    C:> "\Program Files\Java\jdk1.6.0_<version>\bin\javac" MyClass.java

    It's useful to set the PATH permanently so it will persist after rebooting.

    How do I set the PATH permanently?
    To set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:

    1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
    2. Click Advanced > Environment Variables.
    3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:

    C:\Program Files\Java\jdk1.6.0_<version>\bin

    * PATH environment variable is a series of directories separated by semi-colons (;) and is not case sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
    * You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored. If one is already present, update it to jdk1.6.0_<version>\bin.
    * If you are not sure where to add the path, add it to the right end of the PATH in the User Variables.
    * The new path takes effect in each new command window you open after setting the PATH variable.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Or else you can do it temporary, set the path on the working folder as follows.

    Java Code:
    path=D:\Program Files\Java\jdk1.6.0_07\bin\
    actually the above path should be your JDK installation path. The above one can be change depends on your PC installation. Once you do it type javac. If you still get the same error you get initially at runtime, check installation path again.

    This is not a best practice actually. Reason is each time when you run a Java class must do the same thing above before run the class.

    You can do the same thing using AUTOEXEC.BAT file. I advice you that don't do anything there, if you don't have familiar with AUTOEXEC.bat file editing.

  6. #6
    ashin is offline Member
    Join Date
    Nov 2008
    Posts
    71
    Rep Power
    0

    Default

    thank you J-LIve... got it.... also eranga and mr. jordan... :)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    If you have solve the problem please mark it as solved. It's really helpful to all other members.

  8. #8
    ashin is offline Member
    Join Date
    Nov 2008
    Posts
    71
    Rep Power
    0

    Default

    how can i mark it??? tnx :)

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Replies: 28
    Last Post: 10-26-2010, 04:39 AM
  2. javac command not recognized
    By sunshine39 in forum New To Java
    Replies: 7
    Last Post: 03-04-2009, 03:54 AM
  3. '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
  4. Replies: 6
    Last Post: 07-30-2008, 03:50 AM
  5. Replies: 4
    Last Post: 07-20-2007, 04:18 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
  •