How can I set my Cygwin PATH to find javac?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







39















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.










share|improve this question































    39















    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.










    share|improve this question



























      39












      39








      39


      13






      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.










      share|improve this question
















      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.







      java path cygwin javac






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 18 '11 at 15:58









      Paŭlo Ebermann

      61.3k12125183




      61.3k12125183










      asked Feb 7 '11 at 7:09









      liv2hakliv2hak

      5,39930100177




      5,39930100177
























          4 Answers
          4






          active

          oldest

          votes


















          64














          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/





          share|improve this answer



















          • 3





            Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

            – stack1
            Feb 3 '15 at 22:24






          • 6





            you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

            – johanvdw
            Jun 18 '15 at 18:55



















          6














          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:




          • Open DOS shell (type cmd into 'RUN' box) go to C:

          • type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders


          Cygwin configuration:



          go under C:cygwinhome, 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.






          share|improve this answer































            3














            To bring more prominence to the useful comment by @johanvdw:



            If you want to ensure your your javac file path is always know when cygwin starts, you may edit your .bash_profile file. In this example you would add export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" somewhere in the file.



            When Cygwin starts, it'll search directories in PATH and this one for executable files to run.






            share|improve this answer































              2














              If you are still finding that the default wrong Java version (1.7) is being used instead of your Java home directory, then all you need to do is simply change the order of your PATH variable to set JAVA_HOMEbin before your Windows directory in your PATH variable, save it and restart cygwin. Test it out to make sure everything will work fine. It should not have any adverse effect because you want your own Java version to override the default which comes with Windows. Good luck!






              share|improve this answer
























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4918830%2fhow-can-i-set-my-cygwin-path-to-find-javac%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                64














                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/





                share|improve this answer



















                • 3





                  Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                  – stack1
                  Feb 3 '15 at 22:24






                • 6





                  you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                  – johanvdw
                  Jun 18 '15 at 18:55
















                64














                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/





                share|improve this answer



















                • 3





                  Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                  – stack1
                  Feb 3 '15 at 22:24






                • 6





                  you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                  – johanvdw
                  Jun 18 '15 at 18:55














                64












                64








                64







                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/





                share|improve this answer













                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/






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 7 '11 at 7:29









                lwellerlweller

                9,27732937




                9,27732937








                • 3





                  Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                  – stack1
                  Feb 3 '15 at 22:24






                • 6





                  you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                  – johanvdw
                  Jun 18 '15 at 18:55














                • 3





                  Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                  – stack1
                  Feb 3 '15 at 22:24






                • 6





                  you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                  – johanvdw
                  Jun 18 '15 at 18:55








                3




                3





                Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                – stack1
                Feb 3 '15 at 22:24





                Is there some permanent place like windows environment variables where I can simply save the folder location, instead of creating the PATH variable ? Thanks !

                – stack1
                Feb 3 '15 at 22:24




                6




                6





                you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                – johanvdw
                Jun 18 '15 at 18:55





                you can add that command to the file ~/.bashrc then it will always load when you start cygwin.

                – johanvdw
                Jun 18 '15 at 18:55













                6














                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:




                • Open DOS shell (type cmd into 'RUN' box) go to C:

                • type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders


                Cygwin configuration:



                go under C:cygwinhome, 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.






                share|improve this answer




























                  6














                  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:




                  • Open DOS shell (type cmd into 'RUN' box) go to C:

                  • type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders


                  Cygwin configuration:



                  go under C:cygwinhome, 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.






                  share|improve this answer


























                    6












                    6








                    6







                    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:




                    • Open DOS shell (type cmd into 'RUN' box) go to C:

                    • type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders


                    Cygwin configuration:



                    go under C:cygwinhome, 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.






                    share|improve this answer













                    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:




                    • Open DOS shell (type cmd into 'RUN' box) go to C:

                    • type "dir /x" and take note of DOS names (with ~) for "Program Files *" folders


                    Cygwin configuration:



                    go under C:cygwinhome, 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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 21 '15 at 15:37









                    l__LG__ll__LG__l

                    7111




                    7111























                        3














                        To bring more prominence to the useful comment by @johanvdw:



                        If you want to ensure your your javac file path is always know when cygwin starts, you may edit your .bash_profile file. In this example you would add export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" somewhere in the file.



                        When Cygwin starts, it'll search directories in PATH and this one for executable files to run.






                        share|improve this answer




























                          3














                          To bring more prominence to the useful comment by @johanvdw:



                          If you want to ensure your your javac file path is always know when cygwin starts, you may edit your .bash_profile file. In this example you would add export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" somewhere in the file.



                          When Cygwin starts, it'll search directories in PATH and this one for executable files to run.






                          share|improve this answer


























                            3












                            3








                            3







                            To bring more prominence to the useful comment by @johanvdw:



                            If you want to ensure your your javac file path is always know when cygwin starts, you may edit your .bash_profile file. In this example you would add export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" somewhere in the file.



                            When Cygwin starts, it'll search directories in PATH and this one for executable files to run.






                            share|improve this answer













                            To bring more prominence to the useful comment by @johanvdw:



                            If you want to ensure your your javac file path is always know when cygwin starts, you may edit your .bash_profile file. In this example you would add export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" somewhere in the file.



                            When Cygwin starts, it'll search directories in PATH and this one for executable files to run.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 23 '15 at 20:53









                            EconomiCurtisEconomiCurtis

                            93521224




                            93521224























                                2














                                If you are still finding that the default wrong Java version (1.7) is being used instead of your Java home directory, then all you need to do is simply change the order of your PATH variable to set JAVA_HOMEbin before your Windows directory in your PATH variable, save it and restart cygwin. Test it out to make sure everything will work fine. It should not have any adverse effect because you want your own Java version to override the default which comes with Windows. Good luck!






                                share|improve this answer




























                                  2














                                  If you are still finding that the default wrong Java version (1.7) is being used instead of your Java home directory, then all you need to do is simply change the order of your PATH variable to set JAVA_HOMEbin before your Windows directory in your PATH variable, save it and restart cygwin. Test it out to make sure everything will work fine. It should not have any adverse effect because you want your own Java version to override the default which comes with Windows. Good luck!






                                  share|improve this answer


























                                    2












                                    2








                                    2







                                    If you are still finding that the default wrong Java version (1.7) is being used instead of your Java home directory, then all you need to do is simply change the order of your PATH variable to set JAVA_HOMEbin before your Windows directory in your PATH variable, save it and restart cygwin. Test it out to make sure everything will work fine. It should not have any adverse effect because you want your own Java version to override the default which comes with Windows. Good luck!






                                    share|improve this answer













                                    If you are still finding that the default wrong Java version (1.7) is being used instead of your Java home directory, then all you need to do is simply change the order of your PATH variable to set JAVA_HOMEbin before your Windows directory in your PATH variable, save it and restart cygwin. Test it out to make sure everything will work fine. It should not have any adverse effect because you want your own Java version to override the default which comes with Windows. Good luck!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Oct 8 '14 at 15:34









                                    user4121974user4121974

                                    211




                                    211






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4918830%2fhow-can-i-set-my-cygwin-path-to-find-javac%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Plaza Victoria

                                        In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                                        How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...