For a project structure like this:
/myfolder/app/components/owl2vowl.jar
/myfolder/app/uploads/ontology.owl
/myfolder/app.js
I am using OWL2VOWL to convert an ontology into a JSON
I wrote code in app.js to run the jar file with some parameters, which will run the command like this:
java -jar e:\myfolder\app\components\owl2vowl.jar -file e:\myfolder\app\uploads\ontology.owl
Here is the code:
var exec = require('child_process').exec, child;
child = exec('java -jar ' + __dirname + '/components/owl2vowl.jar' + ' -file ' + syncPath ,
function (error, stdout, stderr){
if(error !== null)
console.log('There was an error parsing the ontology' + error);
else
console.log('Succes parsing the ontology');
where
syncPath = e:\myfolder\app\uploads\ontology.owl
The problem is that the result is generated in folder myfolder generating the file ontology.json
How can I change the path where the result of the Java file is generated? Ideally into \app\uploads ?
/myfolder/app/components/owl2vowl.jar
/myfolder/app/uploads/ontology.owl
/myfolder/app.js
/myfolder/ontology.json
Edit - Added solution
the solution a suggested by javabeangrinder is to add a cwd option (in the following, the result will be outputted in the folder /components )
var options = { encoding: 'utf8',
timeout: 0,
maxBuffer: 200*1024,
killSignal: 'SIGTERM',
cwd: __dirname + '/components/',
env: null }
child = exec('java -jar ' + __dirname + '/components/owl2vowl.jar' + ' -iri ' + '"'+body.url+'"'+' -echo' , options,
function (error, stdout, stderr){})
fs.rename(oldPath, newPath), after it is generated?//move file from root to /cached/ fs.rename(getFileName.split(".")[0]+".json", __dirname + '/cached/' + getFileName.split(".")[0]+".json");but the JAR can generate different file names (depending on the point in time when Java is called).outputPathand implement the functionality. It shouldn't be a big deal, something likeexportFile = new File(outputPath, filename)in github.com/VisualDataWeb/OWL2VOWL/blob/master/src/main/java/de/…