Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javac not recognized

Options
  • 24-08-2006 12:44pm
    #1
    Closed Accounts Posts: 73 ✭✭


    After coming across a strange problem, when trying to complile a program using "javac" in command prompt, it tells me it does not recognize the command.
    I am still able to run already compiled java classes using "java".

    I have set my environment variables ie JAVA_HOME=C:/Program Files/Java/jdk1.5.0_06 and also added this to my Path , %JAVA_HOME%\bin,

    Any Ideas??:confused::confused:


Comments

  • Registered Users Posts: 12,583 ✭✭✭✭tunney


    Java ships with windows(i.e. the JRE) and as such is generally always available. Javac is part of the SDK.

    I'd reckon that you path is wrong, echo your path from cmd and see if it looks right.


  • Registered Users Posts: 4,188 ✭✭✭pH


    cd %JAVA_HOME%/bin
    javac
    

    If that works then it's a path problem, if that doesn't work then %JAVA_HOME% is wrong or the javac exe is not in the bin dir


  • Closed Accounts Posts: 73 ✭✭gerryjuice


    Just entered:
    echo %JAVA_HOME%
    Got back
    C:\Program Files\Java\jdk1.5.0_06


  • Registered Users Posts: 5,112 ✭✭✭Blowfish


    you could just try adding the whole thing to the path. i.e. C:\Program Files\Java\jdk1.5.0_06\bin


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    You need to add C:\Program Files\Java\jdk1.5.0_06\bin to the windows %PATH% variable.

    Open a command prompt and type

    PATH = %PATH%;C:\Program Files\Java\jdk1.5.0_06\bin

    ensure you've typed it exactly as above before hitting return.

    If it's still not working, then you'll need to download the SDK.


  • Advertisement
  • Closed Accounts Posts: 73 ✭✭gerryjuice


    OK this is what i have done.
    1. In command prompt, type "javac" - get back "is not recognized"
    2. Type echo %JAVA_HOME% - get back "C:\Program Files\Java\jdk1.5.0_06
    3. type cd %JAVA_HOME%\bin and exceute javac, it works so this i guess tells me my path is wrong.
    4. Cut and paste C:\Program Files\Java\jdk1.5.0_06\bin into path instead of %JAVA_HOME%\bin, - still get "is not recognized".

    Is my next step reinstallation??

    PATH = %PATH%;C:\Program Files\Java\jdk1.5.0_06\bin worked. cheers seamus & lads.


  • Closed Accounts Posts: 73 ✭✭gerryjuice


    Nightmare.
    The reason i needed to make sure javac was ok, was because of an error i was getting in eclipse. "java.lang.NoClassDefFound" ../../../.././Hello" Exception in thread main. This points to the fact that the class was no compiling ie not going from .java to .classs (i think).
    I now try to create new classes in eclipse, and i am getting the same error as before.
    I have uninstalled and reinstalled eclipse already.
    I can run classes that i compile outside of eclipse (ie javac) inside as i have the .class file created.
    If i could do this for every class it would be ok, but i need some api files on my class path which are not in the jdk (which eclipse allows me to do easily),
    Help :confused::confused:


  • Registered Users Posts: 4,188 ✭✭✭pH


    I would say that the error is most likely caused by the class name not matching the java file name

    ie

    - The class Fred must reside in a file called Fred.java (and yes the case is important)
    - Otherwise the class is not in the correct package

    ie
    if the class contains
    package ie.boards;

    then it must be in a direcory ./ie/boards/ (from the root of your java compile tree)

    An eclipse expert could tell you how to check such things in eclipse.


Advertisement