How do I run an external program inside a Java frame in netbeans in a platform independent manner?

前提是你 提交于 2019-12-04 03:42:56

问题


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



来源:https://stackoverflow.com/questions/6524727/how-do-i-run-an-external-program-inside-a-java-frame-in-netbeans-in-a-platform-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!