user1542639 user1542639 - 11 days ago 8
C++ Question

Is there a way to run and control another program with Java? (or C++)

My work requires me to export DBVisualizer's diagram for each table. However, DBVisualizer is not open source, so it does not provide me the API. Additionally, there are over thousand of tables that I need to export. Therefore, is it possible for me to inject or control DBVisualizer via Java or C++ code to export each table information?


There are two things that I know can help with this. One is the ProcessBuilder and the other is Robot.

ProcessBuilder can be used to run external commands. It can be pretty tricky though. I recall the program hanging if it output an error and you failed to stream the content. If the program has no command line API you're limited in what you can do. But you can use it to start up the program.

Robot can literally take control of your computer. You can use it to control the mouse and the keyboard, etc. You need to be careful because if you have a bug in your usage of this, you will lose control of UI and may have to restart your computer.

Neither of these are ideal. You'd be in a better situation if you didn't have to use them but I don't know of anything else you can use.