How to send jar file output to a json file using python Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to get the output from .jar execution in python codes?How do I check whether a file exists without exceptions?How do I copy a file in Python?How do I format a Microsoft JSON date?How can I safely create a nested directory in Python?How can I pretty-print JSON in a shell script?How do I include a JavaScript file in another JavaScript file?Why can't Python parse this JSON data?How do I list all files of a directory?How to read a file line-by-line into a list?How do you append to a file in Python?

How to install press fit bottom bracket into new frame

How to write the following sign?

What is this clumpy 20-30cm high yellow-flowered plant?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

What was the first language to use conditional keywords?

Hangman Game with C++

Is it fair for a professor to grade us on the possession of past papers?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

AppleTVs create a chatty alternate WiFi network

Do wooden building fires get hotter than 600°C?

Why is Nikon 1.4g better when Nikon 1.8g is sharper?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

What would you call this weird metallic apparatus that allows you to lift people?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

What do you call the main part of a joke?

Is there a kind of relay that only consumes power when switching?

Why wasn't DOSKEY integrated with COMMAND.COM?

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Crossing US/Canada Border for less than 24 hours

Sum letters are not two different

How would a mousetrap for use in space work?

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

How could we fake a moon landing now?

How to tell that you are a giant?



How to send jar file output to a json file using python



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to get the output from .jar execution in python codes?How do I check whether a file exists without exceptions?How do I copy a file in Python?How do I format a Microsoft JSON date?How can I safely create a nested directory in Python?How can I pretty-print JSON in a shell script?How do I include a JavaScript file in another JavaScript file?Why can't Python parse this JSON data?How do I list all files of a directory?How to read a file line-by-line into a list?How do you append to a file in Python?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I have jar file when executed will print out the output on the terminal, Im not sure how can i pass the jar file output as a json file.



The code below just print the jar file output on the terminal



subprocess.Popen(['java', '-jar', '/home/myfolder/collect.jar'])


I'm thinking of below but no idea to start with...



with open('collect.json', 'w') as fp:
xxxxxxxxxxx


Hope someone could advise further. Thank you.










share|improve this question






















  • Possible duplicate of How to get the output from .jar execution in python codes?

    – Goyo
    Mar 22 at 11:11











  • I have tried before I post my questions...still failed anyway thanks for your advise..

    – chenoi
    Mar 22 at 11:29

















-1















I have jar file when executed will print out the output on the terminal, Im not sure how can i pass the jar file output as a json file.



The code below just print the jar file output on the terminal



subprocess.Popen(['java', '-jar', '/home/myfolder/collect.jar'])


I'm thinking of below but no idea to start with...



with open('collect.json', 'w') as fp:
xxxxxxxxxxx


Hope someone could advise further. Thank you.










share|improve this question






















  • Possible duplicate of How to get the output from .jar execution in python codes?

    – Goyo
    Mar 22 at 11:11











  • I have tried before I post my questions...still failed anyway thanks for your advise..

    – chenoi
    Mar 22 at 11:29













-1












-1








-1








I have jar file when executed will print out the output on the terminal, Im not sure how can i pass the jar file output as a json file.



The code below just print the jar file output on the terminal



subprocess.Popen(['java', '-jar', '/home/myfolder/collect.jar'])


I'm thinking of below but no idea to start with...



with open('collect.json', 'w') as fp:
xxxxxxxxxxx


Hope someone could advise further. Thank you.










share|improve this question














I have jar file when executed will print out the output on the terminal, Im not sure how can i pass the jar file output as a json file.



The code below just print the jar file output on the terminal



subprocess.Popen(['java', '-jar', '/home/myfolder/collect.jar'])


I'm thinking of below but no idea to start with...



with open('collect.json', 'w') as fp:
xxxxxxxxxxx


Hope someone could advise further. Thank you.







python json file jar






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 10:32









chenoichenoi

258




258












  • Possible duplicate of How to get the output from .jar execution in python codes?

    – Goyo
    Mar 22 at 11:11











  • I have tried before I post my questions...still failed anyway thanks for your advise..

    – chenoi
    Mar 22 at 11:29

















  • Possible duplicate of How to get the output from .jar execution in python codes?

    – Goyo
    Mar 22 at 11:11











  • I have tried before I post my questions...still failed anyway thanks for your advise..

    – chenoi
    Mar 22 at 11:29
















Possible duplicate of How to get the output from .jar execution in python codes?

– Goyo
Mar 22 at 11:11





Possible duplicate of How to get the output from .jar execution in python codes?

– Goyo
Mar 22 at 11:11













I have tried before I post my questions...still failed anyway thanks for your advise..

– chenoi
Mar 22 at 11:29





I have tried before I post my questions...still failed anyway thanks for your advise..

– chenoi
Mar 22 at 11:29












2 Answers
2






active

oldest

votes


















0














This should do the trick. If you look at the subprocess documentation you can see that check_output runs a command with arguments and return its output as a byte string.



import multiprocessing as mp
import subprocess

command = "java -jar /home/myfolder/collect.jar"

def runCommand(q):
commandOutput = subprocess.check_output(command.split()).decode("utf-8")
q.put(commandOutput)

q = mp.Queue()
commandProcess = mp.Process(target=runCommand, args=(q, ))
commandProcess.start()
output = q.get()
print(output)
with open('collect.json', w) as fp:
fp.write(output)


Didn't run the code, but should work.






share|improve this answer

























  • Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

    – chenoi
    Mar 22 at 12:20











  • Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

    – chenoi
    Mar 22 at 12:33











  • @chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

    – willy1994
    Mar 22 at 13:25











  • It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

    – chenoi
    Mar 22 at 13:47


















0














You can try something like this



with open('collect.json','w') as fp :
subprocess.Popen('java -jar .//home/myfolder/collect.jar',stdout=fp).wait()


for further information, see this question How to get the output from .jar execution in python codes?



I hope this helped.






share|improve this answer























  • hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

    – chenoi
    Mar 22 at 12:39











  • I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

    – chenoi
    Mar 22 at 12:44











  • This solution also work... add '[]'..thanks

    – chenoi
    Mar 22 at 13:48











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297697%2fhow-to-send-jar-file-output-to-a-json-file-using-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This should do the trick. If you look at the subprocess documentation you can see that check_output runs a command with arguments and return its output as a byte string.



import multiprocessing as mp
import subprocess

command = "java -jar /home/myfolder/collect.jar"

def runCommand(q):
commandOutput = subprocess.check_output(command.split()).decode("utf-8")
q.put(commandOutput)

q = mp.Queue()
commandProcess = mp.Process(target=runCommand, args=(q, ))
commandProcess.start()
output = q.get()
print(output)
with open('collect.json', w) as fp:
fp.write(output)


Didn't run the code, but should work.






share|improve this answer

























  • Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

    – chenoi
    Mar 22 at 12:20











  • Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

    – chenoi
    Mar 22 at 12:33











  • @chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

    – willy1994
    Mar 22 at 13:25











  • It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

    – chenoi
    Mar 22 at 13:47















0














This should do the trick. If you look at the subprocess documentation you can see that check_output runs a command with arguments and return its output as a byte string.



import multiprocessing as mp
import subprocess

command = "java -jar /home/myfolder/collect.jar"

def runCommand(q):
commandOutput = subprocess.check_output(command.split()).decode("utf-8")
q.put(commandOutput)

q = mp.Queue()
commandProcess = mp.Process(target=runCommand, args=(q, ))
commandProcess.start()
output = q.get()
print(output)
with open('collect.json', w) as fp:
fp.write(output)


Didn't run the code, but should work.






share|improve this answer

























  • Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

    – chenoi
    Mar 22 at 12:20











  • Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

    – chenoi
    Mar 22 at 12:33











  • @chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

    – willy1994
    Mar 22 at 13:25











  • It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

    – chenoi
    Mar 22 at 13:47













0












0








0







This should do the trick. If you look at the subprocess documentation you can see that check_output runs a command with arguments and return its output as a byte string.



import multiprocessing as mp
import subprocess

command = "java -jar /home/myfolder/collect.jar"

def runCommand(q):
commandOutput = subprocess.check_output(command.split()).decode("utf-8")
q.put(commandOutput)

q = mp.Queue()
commandProcess = mp.Process(target=runCommand, args=(q, ))
commandProcess.start()
output = q.get()
print(output)
with open('collect.json', w) as fp:
fp.write(output)


Didn't run the code, but should work.






share|improve this answer















This should do the trick. If you look at the subprocess documentation you can see that check_output runs a command with arguments and return its output as a byte string.



import multiprocessing as mp
import subprocess

command = "java -jar /home/myfolder/collect.jar"

def runCommand(q):
commandOutput = subprocess.check_output(command.split()).decode("utf-8")
q.put(commandOutput)

q = mp.Queue()
commandProcess = mp.Process(target=runCommand, args=(q, ))
commandProcess.start()
output = q.get()
print(output)
with open('collect.json', w) as fp:
fp.write(output)


Didn't run the code, but should work.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 22 at 13:24

























answered Mar 22 at 10:50









willy1994willy1994

663




663












  • Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

    – chenoi
    Mar 22 at 12:20











  • Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

    – chenoi
    Mar 22 at 12:33











  • @chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

    – willy1994
    Mar 22 at 13:25











  • It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

    – chenoi
    Mar 22 at 13:47

















  • Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

    – chenoi
    Mar 22 at 12:20











  • Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

    – chenoi
    Mar 22 at 12:33











  • @chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

    – willy1994
    Mar 22 at 13:25











  • It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

    – chenoi
    Mar 22 at 13:47
















Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

– chenoi
Mar 22 at 12:20





Hi...Im getting error ImportError: No module named mutiprocessing.my pip list does have mutiprocess install

– chenoi
Mar 22 at 12:20













Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

– chenoi
Mar 22 at 12:33





Sorry...typo error of multiprocessing..i run again the code... anyway...the code run but the json file empty...no data on it...

– chenoi
Mar 22 at 12:33













@chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

– willy1994
Mar 22 at 13:25





@chenoi Try the code above again, i fotgot to actually write the file (see fp.write(output))

– willy1994
Mar 22 at 13:25













It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

– chenoi
Mar 22 at 13:47





It works...thank you so much.... i spot the missing pieces earlier...thank you for your attention and support...

– chenoi
Mar 22 at 13:47













0














You can try something like this



with open('collect.json','w') as fp :
subprocess.Popen('java -jar .//home/myfolder/collect.jar',stdout=fp).wait()


for further information, see this question How to get the output from .jar execution in python codes?



I hope this helped.






share|improve this answer























  • hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

    – chenoi
    Mar 22 at 12:39











  • I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

    – chenoi
    Mar 22 at 12:44











  • This solution also work... add '[]'..thanks

    – chenoi
    Mar 22 at 13:48















0














You can try something like this



with open('collect.json','w') as fp :
subprocess.Popen('java -jar .//home/myfolder/collect.jar',stdout=fp).wait()


for further information, see this question How to get the output from .jar execution in python codes?



I hope this helped.






share|improve this answer























  • hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

    – chenoi
    Mar 22 at 12:39











  • I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

    – chenoi
    Mar 22 at 12:44











  • This solution also work... add '[]'..thanks

    – chenoi
    Mar 22 at 13:48













0












0








0







You can try something like this



with open('collect.json','w') as fp :
subprocess.Popen('java -jar .//home/myfolder/collect.jar',stdout=fp).wait()


for further information, see this question How to get the output from .jar execution in python codes?



I hope this helped.






share|improve this answer













You can try something like this



with open('collect.json','w') as fp :
subprocess.Popen('java -jar .//home/myfolder/collect.jar',stdout=fp).wait()


for further information, see this question How to get the output from .jar execution in python codes?



I hope this helped.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 10:42









whoosiswhoosis

138318




138318












  • hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

    – chenoi
    Mar 22 at 12:39











  • I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

    – chenoi
    Mar 22 at 12:44











  • This solution also work... add '[]'..thanks

    – chenoi
    Mar 22 at 13:48

















  • hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

    – chenoi
    Mar 22 at 12:39











  • I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

    – chenoi
    Mar 22 at 12:44











  • This solution also work... add '[]'..thanks

    – chenoi
    Mar 22 at 13:48
















hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

– chenoi
Mar 22 at 12:39





hi....this getting error raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

– chenoi
Mar 22 at 12:39













I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

– chenoi
Mar 22 at 12:44





I add [] as below subprocess.Popen(['java -jar .//home/myfolder/collect.jar'],stdout=fp).wait()

– chenoi
Mar 22 at 12:44













This solution also work... add '[]'..thanks

– chenoi
Mar 22 at 13:48





This solution also work... add '[]'..thanks

– chenoi
Mar 22 at 13:48

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297697%2fhow-to-send-jar-file-output-to-a-json-file-using-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현