Is it possible to run java from Python in order to create a .png?

Multi tool use
Multi tool use


Is it possible to run java from Python in order to create a .png?



I currently have a working java application which from a String renders a .png file. When run from cmd it produces the image in the directory I want. However, when I've tried calling it from Python using


subprocess.call(["java", "-jar", "C:pathtomyjarFilefile.jar",
inputString], shell = True)



no image is created. How can I make it create an image?



Any advice is helpful!





Is it a typo or do you have ` and ` in your path?
– FlyingTeller
Jul 3 at 8:54


` and





Do you use relative paths in your java programm? Also is the file overwritten from java?
– Lino
Jul 3 at 8:54






add logging to both your python and your java application to help with your debugging.
– Mike Scotty
Jul 3 at 8:57





I'm not familiar with Windows platform but don't you need double in your path? Such as C:pathtomyjarFilefile.jar?
– Sraw
Jul 3 at 9:02




C:pathtomyjarFilefile.jar





I've tried it with both relative and absolute paths and have not had success yet. And is it wrong to have "" in my path? I've used it with Popen and haven't had any issues. And I have `` where Python recommends it. Tried editing it so that I have double backslashes everywhere but did not help unfortunately.
– Isak
Jul 3 at 9:04





1 Answer
1



You could read the process output message to debug it, example code:


inputString = ''
ps = subprocess.Popen(["java", "-jar", "C:pathtomyjarFilefile.jar", inputString],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
val = ps.stdout.read()
print("val: " + val)



and in my pc, it output error like this:



val: Error: Unable to access jarfile C:path omyjarFileile.jar





Solved it, had some syntax error. Thanks for the help!
– Isak
Jul 3 at 9:20






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

8,c6,dkxyFtHk9xsi13,1c8bMbbYA ZC,VoLelI1SSN0Ya0fd17rw6KO3ZaUaA9wEuE1Wx
aPpnmRfgU yAdTfVqfAB4vAxFREM y2Sw,piuPoVkLTH6 ICTT,wJ B fGG6 Aa8ceDAjkwMy q7e2

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications