How do I run an external program inside a Java fra

2019-02-23 08:14发布

问题:

I am currently working on a research project for a University in which I am doing GUI interactions with my database and launching an external program based on the data. I'm using runtime commands (once the OS is detected) to launch that external program with the selected data.

My question is how can I embed an external program's GUI inside a Java frame, if that is even remotely possible?

回答1:

Given the clarifying comments on the question, the short answer is "no, you can't do that".

Java cannot display a native program's GUI within a JFrame, even if the target program was actually architected to allow it's GUI to be presented within another program's frame.



回答2:

Are you using a console application? You have to intercept its stdout to do it correctly. So you can show the text that the 3rd party application is outputting in an UI control that you can put into JFrame.



回答3:

Use java.lang.Process or java.lang.Runtime.exec.

http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html



标签: java external