Results 1 to 10 of 10

Thread: Javac Error

  1. #1
    Rambo is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Javac Error

    Hi,

    I am new to java. I get a javac error when i compile my program. Have seen similar error being discussed in various forums and have followed the steps as adviced, I am still unable to get past this error.


    Details are as below
    I have a 32 bit laptop on Window 7. I have installed JDK and javac is in the following path
    C:\Program Files\Java\jdk1.7.0_11\bin

    I have edited my eniornment variables PATH to
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static; C:\Program Files\Java\jdk1.7.0_11\bin

    And PATHCLASS to .

    MyFirst Java program is in the folder
    C:\Users\user\Documents\Java

    public class HelloWorld{
    public static void main (string[] args){
    system.out.println("Hello World");
    }
    }


    Its saved as a JAVA file

    In the terminal

    set path = C:\Program Files\Java\jdk1.7.0_11\bin

    cd C:\Users\user\Documents\Java

    javac HelloWorld.Java

    I get the error Javac is not recognisable as an internal or external command.

    Please help!!

    Thanks

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

    Default Re: Javac Error

    Quote Originally Posted by Rambo View Post
    And PATHCLASS to .
    The variable is CLASSPATH and you do not need this at all.
    It's Bad Practice.

    Quote Originally Posted by Rambo View Post
    In the terminal

    set path = C:\Program Files\Java\jdk1.7.0_11\bin
    No need to do this as you've already set the PATH variable.

    Quote Originally Posted by Rambo View Post
    cd C:\Users\user\Documents\Java

    javac HelloWorld.Java

    I get the error Javac is not recognisable as an internal or external command.
    Remove the classpath variable and don't set the PATH variable in the terminal and then see if it works in a new terminal.
    Copy the exact output and paste it here if it still doesn't work.
    Last edited by Tolls; 02-01-2013 at 11:31 AM.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Rambo is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: Javac Error

    Hi,
    Thanks for your reply. I have now deleted the PATHCLASS and executed the following steps
    cd C:\Users\user\Documents\Java
    javac HelloWorld.java

    The error is 'javac' is not recognized as an internal or external command,operable program or batch file

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

    Default Re: Javac Error

    Go to the directory where javac.exe is stored (somewhere in C:\Program Files\JDKxxx\bin) and type ".\javac -version"; you'll see some output from your java compiler. Now add that directory to your PATH variable (not the CLASSPATH variable) so the OS knows where to find your compiler. Note that this is not a java issue at all; it's basic OS knowledge. The Java installation copies java.exe (the virtual machine itself) to a well known location so there is no need to add its directory to the PATH variable; not so with your compiler javac.exe.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Rambo is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: Javac Error

    Hi Josh,
    This is what I did
    cd C:\Program Files\Java\jdk1.7.0_11\bin

    ".\javac" -version
    It displays javac 1.7.0_11

    I have previous ly added the path
    C:\Program Files\Java\jdk1.7.0_11\bin
    to the PATH variable.

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

    Default Re: Javac Error

    Can you print (copy/paste) your PATH variable here?
    Something's not right.

    In fact just show the PATH variable from your terminal (C:\ path) and paste it here.
    That's probably more useful.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Rambo is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: Javac Error

    Javac Error-cpath.jpg

    Hi Tolls, Please find the image attached. TA

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

    Default Re: Javac Error

    There isn't a <space> between the last ';' and the 'C:\' is there?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Rambo is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: Javac Error

    Yes there was a space. I removed the space and was able to compile and run the program.

    Thank you for your help and patience.

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

    Default Re: Javac Error

    It's annoyingly inflexible, isn't it?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Different 'javac not recognized' error
    By dgbarnett06 in forum New To Java
    Replies: 4
    Last Post: 07-03-2012, 07:29 PM
  2. 'Javac' Not Recognized Error
    By Rahim2312 in forum New To Java
    Replies: 15
    Last Post: 04-30-2012, 09:27 PM
  3. Javac error
    By Sotsiak in forum New To Java
    Replies: 5
    Last Post: 06-04-2010, 09:33 AM
  4. Javac error
    By Zorobay in forum New To Java
    Replies: 14
    Last Post: 03-03-2010, 01:00 AM
  5. ===javac error===
    By solt in forum New To Java
    Replies: 21
    Last Post: 12-06-2009, 10: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
  •