node.js - Calling Java from NodeJS outputs file in root -


for project structure this:

/myfolder/app/components/owl2vowl.jar /myfolder/app/uploads/ontology.owl /myfolder/app.js 

i using owl2vowl convert ontology json

i wrote code in app.js run jar file parameters, run command this:

java -jar e:\myfolder\app\components\owl2vowl.jar -file e:\myfolder\app\uploads\ontology.owl  

here 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 error parsing ontology' + error);   else                console.log('succes parsing ontology'); 

where

syncpath = e:\myfolder\app\uploads\ontology.owl  

the problem result generated in folder myfolder generating file ontology.json

how can change path result of java file generated? ideally \app\uploads ?

/myfolder/app/components/owl2vowl.jar /myfolder/app/uploads/ontology.owl /myfolder/app.js /myfolder/ontology.json 

edit - added solution

the solution suggested javabeangrinder add cwd option (in following, result outputted in 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){}) 

the problem not java code although fixed changing accept output folder suggested earlier.

i believe adding node.js exec option cwd directory output trick.

look further here: child_process.exec(command[, options], callback)


Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -