Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

Can I run cygwin java through bash script?

Asked by Lauren Hardacre Oct 10, 2022 1.1K views 1 answer
Share

About 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= "$home dir/folder/$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.


Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.