0

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.

  • 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
0

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:\cygwin64\home\tony\screenshot.jpg
0

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.