Hi Arun

The question was about a "javac file not found" error. There is no need to know anything about classpath to avoid this error.

The PATH system variable normally contains a list of directories where the operating system (OS) looks for files when the explicit path is not specified. For e.g. when you type "ipconfig" at the Windows/DOS command prompt, it executes the file "C:\Windows\system32\ipconfig.exe" because the directory "C:\Windows\system32" is listed in the %PATH%. In the same way, most of Unix/Linux/OS-X commands are executable binary files that exist in "/usr/bin" and "/user/bin" is listed in the $PATH.

The CLASSPATH system variable contains a list of directories where Java looks for files (namely packages and their contained classes). Instead of creating a CLASSPATH variable, there are other ways to specify the list of directories, such as using the "-cp" option for the java or javac command. There are several long discussions about the CLASSPATH, look for answers containing "classpath" in the subject around the 30th ot the 31st of August.

If you wish, you may put that in this way:
-- The OS is a "program", executed by the machine. In order to find the files it needs (when the place is not explicitly specified), there are some "default" places to look for. The "default" places are contained in the PATH (system variable). -- The Java virtual machine (JVM) is a "program", executed by the OS. In order to ind the files it needs (when they are not in the current directory), there are some "default" places to look for. The "default" places are contained in the CLASSPATH.

Now:
-- In order to let the OS to find javac, its directory has to be listed in the PATH system variable, unless you explicitly specify its full pahtname. -- In order to let javac to find the packages that contains the classes referenced by the code to compile, their directories must be listed in the CLASSPATH system variable (or the equivalent information is passed by "-cp"), unless they are in the current directory (the "." is usually the default value for the classpath).

So:
-- In order to be able to execute (start) "javac", all you have to think about is PATH. -- In order to make it working (compiling), you might need to think to CLASSPATH too.

Hope it helps
Mihai


Le 19/09/2010 08:40, Arun Kumar a écrit :
Dear mihai

Do u know about classpath. In below solution u are not mention classpath concept.
Why.

With regards
Arun Kumar

On Tue, Sep 14, 2010 at 2:13 AM, Mihai DINCA <mihai.di...@free.fr <mailto:mihai.di...@free.fr>> wrote:

    Hi Sathvavathi,

    If you use some integrated programming environment like Eclipse or
    NetBeans, it takes care about the location of the *javac*
    compiler. But if you try to executed it by hand, be sure it is in
    the PATH.

    For e.g., under Windows, if your JDK is installed in "*C:\Program
    Files\myJavaSDK*", probably the *javac.exe* is in "*C:\Program
    Files\myJavaSDK\bin*". In this case, do create in the current
    directory the file "*/setenv.bat/*":

        *> notepad setenv.bat
        *

    with the following content:

        *SET JAVAHOME=C:\Program Files\myJavaSDK
        SET PATH="%JAVAHOME%\bin";%PATH%*

    (please notice the double quotes " - mandatory if your JAVAHOME
    contains any white space).

    Then execute first /*setenv.bat*/:

        *> setenv*

    and compile using javac only after.

    The same thing applies if you are trying to compile on GNU Linux
    or Unix. Let's say that your *javac* compiler is in
    "*/usr/local/java files/bin*". In this case, do create in the
    current directory the file "/*sentenv.sh*/":

        *> kate setenv.sh
        *

    (your currently installed editor must be different from /kate/)
    with the following content:

        *export JAVAHOME=/usr/local/java\ files*
        *export PATH=$JAVAHOME/bin:$PATH*

    (there is no quote, but exotic characters, such as the space, must
    be preceded by the escape character "*\*"; other differences: the
    separator character in the PATH is the colon "*:*" instead of the
    semicolon "*;*" and the environment variables are prefixed by
    "*$*" instead of being surrounded by "*%*").

    Then execute first /*setenv.sh*/:

        *> chmod a+x setenv.sh
        > ./setenv.sh*

    and compile using javac only after.

    Hope it helps
    Mihai

    Le 13/09/2010 09:27, Sathyavathi Sekar a écrit :


    --- On *Sun, 9/12/10, Sathyavathi Sekar
    /<sathyavathi_sr...@yahoo.com>
    <mailto:sathyavathi_sr...@yahoo.com>/* wrote:


        From: Sathyavathi Sekar <sathyavathi_sr...@yahoo.com>
        <mailto:sathyavathi_sr...@yahoo.com>
        Subject:
        To: javaprogrammingwithpassion@googlegroups.com
        <mailto:javaprogrammingwithpassion@googlegroups.com>
        Date: Sunday, September 12, 2010, 10:25 PM

        hi i am new to java programming .in the command prompt,i am
        getting error as javac file cannot be found or the or
        thesystem cannot find the path specified. what should i do?



-- To post to this group, send email to
    javaprogrammingwithpassion@googlegroups.com
    <mailto:javaprogrammingwithpassion@googlegroups.com>
    To unsubscribe from this group, send email to
    javaprogrammingwithpassion+unsubscr...@googlegroups.com
    <mailto:javaprogrammingwithpassion+unsubscr...@googlegroups.com>
    For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-- To post to this group, send email to
    javaprogrammingwithpassion@googlegroups.com
    <mailto:javaprogrammingwithpassion@googlegroups.com>
    To unsubscribe from this group, send email to
    javaprogrammingwithpassion+unsubscr...@googlegroups.com
    <mailto:javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
    For more options, visit this group at
    http://groups.google.com/group/javaprogrammingwithpassion?hl=en



--
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to