I have a Windows 7 system on which I have installed the latest Java compiler. I also have the latest Cygwin. I want to use the Java compiler from Cygwin's shell. I edited the PATH variable in Cygwin as follows:
export PATH=$PATH:"/cygdrive/C/Program\ Files/Java/jdk1.6.0_23/bin/"
I can see the javac
binary in the above directory, however when I try to compile my *.java file I get:
javac command not found
Am I doing something wrong in setting the PATH variable like this? Do I have to do something else? I am new to Java and not very familiar with cygwin.
Update the PATH environment variable: From the Start menu, select Parameters > Control Panel > System. Select the Advanced tab and click Environment variables. Edit the PATH environment variable to add the Cygwin installation directory, for example c:\cygwin\bin; and click OK.
I.e. DOS C: drive can be accessed in Cygwin by /cygdrive/c, D: as /cygdrive/d, etc. To display the contents of the current directory, you can use ls or dir commands. ls -la will provide more details, including file access permissions, size and modification date.
as you write the it with double-quotes, you don't need to escape spaces with \
export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/"
of course this also works:
export PATH=$PATH:/cygdrive/C/Program\ Files/Java/jdk1.6.0_23/bin/
Java binaries may be under "Program Files" or "Program Files (x86)": those white spaces will likely affect the behaviour.
In order to set up env variables correctly, I suggest gathering some info before starting:
Cygwin configuration:
go under C:\cygwin\home\, then open .bash_profile and add the following two lines (conveniently customized in order to match you actual JDK path)
export JAVA_HOME="/cygdrive/c/PROGRA~1/Java/jdk1.8.0_65" export PATH="$JAVA_HOME/bin:$PATH"
Now from Cygwin launch
javac -version
to check if the configuration is successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With