Results 1 to 15 of 15

Thread: Javac error

  1. #1
    Zorobay is offline Member
    Join Date
    Feb 2010
    Posts
    12
    Rep Power
    0

    Default Javac error

    When i try to compile my first java project i get this message

    "'Javac' is not recognized as an internal or external command, operable program or batch file"
    Can anyone explain in a simple way how to solve this?

  2. #2
    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

    How you compile your code?

    This is happen because the class path is not set properly. Can you provide more details?

  3. #3
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Maybe all that's wrong is the capitalization, it's javac, not Javac.

  4. #4
    Zorobay is offline Member
    Join Date
    Feb 2010
    Posts
    12
    Rep Power
    0

    Default

    No i type exactly "javac" not "Javac" and i compile it using javac HelloWorldApp.java when I am in the directory of the java file.

  5. #5
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    So you downloaded and installed java somewhere on your machine.

    Let's say your 'javac.exe' is here:

    C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe

    In command prompt use full path to javac.exe with " " to compile your src
    "C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe"

    Other solution is to add
    C:\Program Files\Java\jdk1.6.0_16\bin
    to env variable called 'Path':

    Start => Control Panel => System => Advanced =>Environment Variables.
    Find 'Path' variable, click Edit button and in
    Variable value on the end of existing value (don't delete it!) add:
    C:\Program Files\Java\jdk1.6.0_16\bin
    Click OK.

    Restart Command prompt and just type
    javac

    cheers!

  6. #6
    Zorobay is offline Member
    Join Date
    Feb 2010
    Posts
    12
    Rep Power
    0

    Default

    Um i ain't got the JDK i only got the Jre. is that enough?

    Or w8 i do. But i didn't work!

    No! It did work!! Thanks!!!
    Last edited by Zorobay; 02-14-2010 at 01:07 PM.

  7. #7
    Zorobay is offline Member
    Join Date
    Feb 2010
    Posts
    12
    Rep Power
    0

    Default

    But no it didn't work!!!

    Now it sais that javac:File not found: Hej.java
    Usage: javac <options> <source files>

    But i am in the direction of my java file! (I just put it in C:\) and it still doesn't find it!

    HELP!

  8. #8
    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 your java file in C drive, first change the directory path to that drive.

    Did you setup the class path? To check that type "javac" abd press enter,what happen?

    if the path setup correctly it should work.

  9. #9
    jason.3dmagic is offline Member
    Join Date
    Oct 2009
    Posts
    30
    Rep Power
    0

    Smile

    do you have jdk?? install it its free u knw...

    if you are using microsoft xp and above

    right-click on my computer---> click on advance tab---> environment variables ----> in system variables--->> add variable JAVA_HOME and value c:\program files\java\jdk(version)


    Regards,

  10. #10
    Zorobay is offline Member
    Join Date
    Feb 2010
    Posts
    12
    Rep Power
    0

    Default

    Um now it works better. Or not. God damn it!

    Okay new error.

    C:\Java>javac Hej.java
    Hej.java:4: cannot find symbol
    symbol : class string
    location: class Hej
    public static void main (string[] arg) <

    1 error

    Note: they are pointing at the s in "string[]"
    Note 2: Hej means Hello in swedish.

    Help please!

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

    Default

    Quote Originally Posted by Zorobay View Post
    Um now it works better. Or not. God damn it!

    Okay new error.

    C:\Java>javac Hej.java
    Hej.java:4: cannot find symbol
    symbol : class string
    location: class Hej
    public static void main (string[] arg) <

    1 error

    Note: they are pointing at the s in "string[]"
    Note 2: Hej means Hello in swedish.

    Help please!
    Java is case sensitive; it has a String class, not a string class (uppercase S). Read your book and/or the API documentation more carefully.

    kind regards,

    Jos

  12. #12
    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

    Means that,

    Java Code:
    public static void main (string[] arg)
    must changed to,

    Java Code:
    public static void main (String[] arg)

  13. #13
    king2be98 is offline Member
    Join Date
    Mar 2010
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by FON View Post
    So you downloaded and installed java somewhere on your machine.

    Let's say your 'javac.exe' is here:

    C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe

    In command prompt use full path to javac.exe with " " to compile your src
    "C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe"

    Other solution is to add
    C:\Program Files\Java\jdk1.6.0_16\bin
    to env variable called 'Path':

    Start => Control Panel => System => Advanced =>Environment Variables.
    Find 'Path' variable, click Edit button and in
    Variable value on the end of existing value (don't delete it!) add:
    C:\Program Files\Java\jdk1.6.0_16\bin
    Click OK.

    Restart Command prompt and just type
    javac

    cheers!
    Ok I've tried to follow these steps but in order to the last one, which will probably be the most suitable solution I need to state some points.

    I've got a 64 bit version of Windows and so I have a folder for JDK1.6.0.... in my program files folder and I also have both jre6 folders in program files and also program files x64 folders. I'm guessing it will still be ok?

  14. #14
    king2be98 is offline Member
    Join Date
    Mar 2010
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by FON View Post

    Start => Control Panel => System => Advanced =>Environment Variables.
    Find 'Path' variable, click Edit button and in
    Variable value on the end of existing value (don't delete it!) add:
    C:\Program Files\Java\jdk1.6.0_16\bin
    Click OK.
    Another question regarding this, you said add onto the existing value, but if that is the case then I'll get

    C:\Sun\SDK\bin C:\Program Files\Java\jdk1.6.0_16\bin

    Surely just the latter would be ok? Or should I keep both in the PATH?

  15. #15
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    Regarding paths - my example is written for Windows XP Professional 32 bit SP3.

    When you add those variable values
    take care how you separate them, use ";" (without "")

Similar Threads

  1. error while compile code using javac
    By suri in forum New To Java
    Replies: 3
    Last Post: 01-20-2010, 09:10 AM
  2. ===javac error===
    By solt in forum New To Java
    Replies: 21
    Last Post: 12-06-2009, 09:18 AM
  3. Replies: 3
    Last Post: 08-14-2009, 12:57 PM
  4. javac DOS
    By rdunne in forum New To Java
    Replies: 3
    Last Post: 01-01-2008, 11:49 AM
  5. Replies: 2
    Last Post: 07-30-2007, 08:55 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
  •