Running JAVA in Cygwin through bash script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I've been encountering a problem with cygwin where I cannot run a jar file with an error that the file cannot be found.



If it were easier i would "translate" the java source in bash, but unfortunately, due to the functionality implemented, there are some quite significant obstacles to achieve this, so I'd have to use the jar file.



Now, I've done a fair amount of research on my part to figure out how to do this, however, I couldn't succeed, and it is mandatory that i use cygwin.



Here's what I'm trying to essentially do:



lockfile="$specialfolder/$passedargument.lock
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar -joption cygpath -w $lockfile`


i also tried with double back-ticks, as follows:



pathtooutfile="$some_other_vars/$that_$work.out"
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar` -joption `cygpath -w $lockfile`


i also tried using the $JAVA_HOME env var but that did not work as well. It is important to mention that the variables being called in lockfile var are defined as follows:



 homedir= "/cygdrive/driveletter/folder/folder"
specialfolder= "$homedir/foler/$passedargument"
passedargument= $1 ###argument passed with execution of bash script
lockfile= "$specialfolder/$passedargument"


The error i keep getting is this: Error: Unable to access jarfile
I have modified usage rights to 777 and that didn't work either. It might also be important to mention that -joption is either -aquire or -release corresponding to the lockfile since one of the things the jar does is manage multiple script executions through a lock file.
I'm somewhat stuck so, any suggestions will be greatly appreciated. I think that this might be more of a cygwin issue.










share|improve this question
















bumped to the homepage by Community♦ 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
    – EightBitTony
    Mar 10 '16 at 9:22










  • always Error: Unable to access jarfile
    – Nikolai Uzunov
    Mar 10 '16 at 9:45










  • So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
    – EightBitTony
    Mar 10 '16 at 10:16











  • it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
    – Nikolai Uzunov
    Mar 10 '16 at 10:51






  • 1




    Then edit your question with that detail, because right now, that's not what your question is asking.
    – EightBitTony
    Mar 10 '16 at 14:02














up vote
0
down vote

favorite












I've been encountering a problem with cygwin where I cannot run a jar file with an error that the file cannot be found.



If it were easier i would "translate" the java source in bash, but unfortunately, due to the functionality implemented, there are some quite significant obstacles to achieve this, so I'd have to use the jar file.



Now, I've done a fair amount of research on my part to figure out how to do this, however, I couldn't succeed, and it is mandatory that i use cygwin.



Here's what I'm trying to essentially do:



lockfile="$specialfolder/$passedargument.lock
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar -joption cygpath -w $lockfile`


i also tried with double back-ticks, as follows:



pathtooutfile="$some_other_vars/$that_$work.out"
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar` -joption `cygpath -w $lockfile`


i also tried using the $JAVA_HOME env var but that did not work as well. It is important to mention that the variables being called in lockfile var are defined as follows:



 homedir= "/cygdrive/driveletter/folder/folder"
specialfolder= "$homedir/foler/$passedargument"
passedargument= $1 ###argument passed with execution of bash script
lockfile= "$specialfolder/$passedargument"


The error i keep getting is this: Error: Unable to access jarfile
I have modified usage rights to 777 and that didn't work either. It might also be important to mention that -joption is either -aquire or -release corresponding to the lockfile since one of the things the jar does is manage multiple script executions through a lock file.
I'm somewhat stuck so, any suggestions will be greatly appreciated. I think that this might be more of a cygwin issue.










share|improve this question
















bumped to the homepage by Community♦ 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
    – EightBitTony
    Mar 10 '16 at 9:22










  • always Error: Unable to access jarfile
    – Nikolai Uzunov
    Mar 10 '16 at 9:45










  • So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
    – EightBitTony
    Mar 10 '16 at 10:16











  • it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
    – Nikolai Uzunov
    Mar 10 '16 at 10:51






  • 1




    Then edit your question with that detail, because right now, that's not what your question is asking.
    – EightBitTony
    Mar 10 '16 at 14:02












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've been encountering a problem with cygwin where I cannot run a jar file with an error that the file cannot be found.



If it were easier i would "translate" the java source in bash, but unfortunately, due to the functionality implemented, there are some quite significant obstacles to achieve this, so I'd have to use the jar file.



Now, I've done a fair amount of research on my part to figure out how to do this, however, I couldn't succeed, and it is mandatory that i use cygwin.



Here's what I'm trying to essentially do:



lockfile="$specialfolder/$passedargument.lock
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar -joption cygpath -w $lockfile`


i also tried with double back-ticks, as follows:



pathtooutfile="$some_other_vars/$that_$work.out"
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar` -joption `cygpath -w $lockfile`


i also tried using the $JAVA_HOME env var but that did not work as well. It is important to mention that the variables being called in lockfile var are defined as follows:



 homedir= "/cygdrive/driveletter/folder/folder"
specialfolder= "$homedir/foler/$passedargument"
passedargument= $1 ###argument passed with execution of bash script
lockfile= "$specialfolder/$passedargument"


The error i keep getting is this: Error: Unable to access jarfile
I have modified usage rights to 777 and that didn't work either. It might also be important to mention that -joption is either -aquire or -release corresponding to the lockfile since one of the things the jar does is manage multiple script executions through a lock file.
I'm somewhat stuck so, any suggestions will be greatly appreciated. I think that this might be more of a cygwin issue.










share|improve this question















I've been encountering a problem with cygwin where I cannot run a jar file with an error that the file cannot be found.



If it were easier i would "translate" the java source in bash, but unfortunately, due to the functionality implemented, there are some quite significant obstacles to achieve this, so I'd have to use the jar file.



Now, I've done a fair amount of research on my part to figure out how to do this, however, I couldn't succeed, and it is mandatory that i use cygwin.



Here's what I'm trying to essentially do:



lockfile="$specialfolder/$passedargument.lock
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar -joption cygpath -w $lockfile`


i also tried with double back-ticks, as follows:



pathtooutfile="$some_other_vars/$that_$work.out"
java -jar `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar` -joption `cygpath -w $lockfile`


i also tried using the $JAVA_HOME env var but that did not work as well. It is important to mention that the variables being called in lockfile var are defined as follows:



 homedir= "/cygdrive/driveletter/folder/folder"
specialfolder= "$homedir/foler/$passedargument"
passedargument= $1 ###argument passed with execution of bash script
lockfile= "$specialfolder/$passedargument"


The error i keep getting is this: Error: Unable to access jarfile
I have modified usage rights to 777 and that didn't work either. It might also be important to mention that -joption is either -aquire or -release corresponding to the lockfile since one of the things the jar does is manage multiple script executions through a lock file.
I'm somewhat stuck so, any suggestions will be greatly appreciated. I think that this might be more of a cygwin issue.







bash java cygwin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 10 '16 at 9:19

























asked Mar 10 '16 at 8:58









Nikolai Uzunov

105




105





bumped to the homepage by Community♦ 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community♦ 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.













  • What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
    – EightBitTony
    Mar 10 '16 at 9:22










  • always Error: Unable to access jarfile
    – Nikolai Uzunov
    Mar 10 '16 at 9:45










  • So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
    – EightBitTony
    Mar 10 '16 at 10:16











  • it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
    – Nikolai Uzunov
    Mar 10 '16 at 10:51






  • 1




    Then edit your question with that detail, because right now, that's not what your question is asking.
    – EightBitTony
    Mar 10 '16 at 14:02
















  • What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
    – EightBitTony
    Mar 10 '16 at 9:22










  • always Error: Unable to access jarfile
    – Nikolai Uzunov
    Mar 10 '16 at 9:45










  • So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
    – EightBitTony
    Mar 10 '16 at 10:16











  • it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
    – Nikolai Uzunov
    Mar 10 '16 at 10:51






  • 1




    Then edit your question with that detail, because right now, that's not what your question is asking.
    – EightBitTony
    Mar 10 '16 at 14:02















What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
– EightBitTony
Mar 10 '16 at 9:22




What does cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar return if you run it on its own. (Please add the output to your question, not as a comment).
– EightBitTony
Mar 10 '16 at 9:22












always Error: Unable to access jarfile
– Nikolai Uzunov
Mar 10 '16 at 9:45




always Error: Unable to access jarfile
– Nikolai Uzunov
Mar 10 '16 at 9:45












So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
– EightBitTony
Mar 10 '16 at 10:16





So the command, cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar on its own, with nothing else, gives you that error? Can you copy and paste you typing that command in and the output? In the question. You are using c or d (or something) in place of driveletter, rather than the word driveletter?
– EightBitTony
Mar 10 '16 at 10:16













it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
– Nikolai Uzunov
Mar 10 '16 at 10:51




it gives me the path to the file in unix format, and yes i am using an actual drive letter like "d" for example
– Nikolai Uzunov
Mar 10 '16 at 10:51




1




1




Then edit your question with that detail, because right now, that's not what your question is asking.
– EightBitTony
Mar 10 '16 at 14:02




Then edit your question with that detail, because right now, that's not what your question is asking.
– EightBitTony
Mar 10 '16 at 14:02










2 Answers
2






active

oldest

votes

















up vote
0
down vote













Have you tried cygpath -w -a .....



The -a returns absolute paths.



e.g.



$ cygpath -w ./screenshot.jpg
screenshot.jpg

$ cygpath -w -a ./screenshot.jpg
C:cygwin64hometonyscreenshot.jpg





share|improve this answer



























    up vote
    0
    down vote













    If your expression



    `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar`


    has embedded blanks, you should put double-quotes around it so that the result is passed to Java as a single token. It can help to understand the expressions and results if you turn on the shell trace, e.g., set -x.



    Further reading:



    • cygpath — Convert Unix and Windows format paths, or output system path information

    • Making Cygwin and Windows cooperate





    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      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',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f268855%2frunning-java-in-cygwin-through-bash-script%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      Have you tried cygpath -w -a .....



      The -a returns absolute paths.



      e.g.



      $ cygpath -w ./screenshot.jpg
      screenshot.jpg

      $ cygpath -w -a ./screenshot.jpg
      C:cygwin64hometonyscreenshot.jpg





      share|improve this answer
























        up vote
        0
        down vote













        Have you tried cygpath -w -a .....



        The -a returns absolute paths.



        e.g.



        $ cygpath -w ./screenshot.jpg
        screenshot.jpg

        $ cygpath -w -a ./screenshot.jpg
        C:cygwin64hometonyscreenshot.jpg





        share|improve this answer






















          up vote
          0
          down vote










          up vote
          0
          down vote









          Have you tried cygpath -w -a .....



          The -a returns absolute paths.



          e.g.



          $ cygpath -w ./screenshot.jpg
          screenshot.jpg

          $ cygpath -w -a ./screenshot.jpg
          C:cygwin64hometonyscreenshot.jpg





          share|improve this answer












          Have you tried cygpath -w -a .....



          The -a returns absolute paths.



          e.g.



          $ cygpath -w ./screenshot.jpg
          screenshot.jpg

          $ cygpath -w -a ./screenshot.jpg
          C:cygwin64hometonyscreenshot.jpg






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 10 '16 at 9:25









          EightBitTony

          15.6k34454




          15.6k34454






















              up vote
              0
              down vote













              If your expression



              `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar`


              has embedded blanks, you should put double-quotes around it so that the result is passed to Java as a single token. It can help to understand the expressions and results if you turn on the shell trace, e.g., set -x.



              Further reading:



              • cygpath — Convert Unix and Windows format paths, or output system path information

              • Making Cygwin and Windows cooperate





              share|improve this answer


























                up vote
                0
                down vote













                If your expression



                `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar`


                has embedded blanks, you should put double-quotes around it so that the result is passed to Java as a single token. It can help to understand the expressions and results if you turn on the shell trace, e.g., set -x.



                Further reading:



                • cygpath — Convert Unix and Windows format paths, or output system path information

                • Making Cygwin and Windows cooperate





                share|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  If your expression



                  `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar`


                  has embedded blanks, you should put double-quotes around it so that the result is passed to Java as a single token. It can help to understand the expressions and results if you turn on the shell trace, e.g., set -x.



                  Further reading:



                  • cygpath — Convert Unix and Windows format paths, or output system path information

                  • Making Cygwin and Windows cooperate





                  share|improve this answer














                  If your expression



                  `cygpath -w ./cygdrive/driveletter/folder/folder/javafile.jar`


                  has embedded blanks, you should put double-quotes around it so that the result is passed to Java as a single token. It can help to understand the expressions and results if you turn on the shell trace, e.g., set -x.



                  Further reading:



                  • cygpath — Convert Unix and Windows format paths, or output system path information

                  • Making Cygwin and Windows cooperate






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 10 '16 at 9:32

























                  answered Mar 10 '16 at 9:23









                  Thomas Dickey

                  50.1k587156




                  50.1k587156



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f268855%2frunning-java-in-cygwin-through-bash-script%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?