Running JAVA in Cygwin through bash script
Clash 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.
bash java cygwin
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.
 |Â
show 4 more comments
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.
bash java cygwin
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 doescygpath -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 usingc
ord
(or something) in place ofdriveletter
, rather than the worddriveletter
?
â 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
 |Â
show 4 more comments
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.
bash java cygwin
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
bash java cygwin
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 doescygpath -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 usingc
ord
(or something) in place ofdriveletter
, rather than the worddriveletter
?
â 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
 |Â
show 4 more comments
What doescygpath -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 usingc
ord
(or something) in place ofdriveletter
, rather than the worddriveletter
?
â 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
 |Â
show 4 more comments
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered Mar 10 '16 at 9:25
EightBitTony
15.6k34454
15.6k34454
add a comment |Â
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited Mar 10 '16 at 9:32
answered Mar 10 '16 at 9:23
Thomas Dickey
50.1k587156
50.1k587156
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 usingc
ord
(or something) in place ofdriveletter
, rather than the worddriveletter
?â 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