How to turn a can of Gui into a command line can?

I am currently working on a large project. We are using a code from a provider and we want to include one of our banners in our software.

This jar is currently being used to restore data and asks for the location of the backup file through a GUI.

I have checked with the supplier, I cannot use this jar in full command line.

I want to know if I can make some sort of shell that can populate and use this GUI without showing the actual GUI showing?

+3


source to share


2 answers


You have to understand - this is not about JAR files . A JAR file is simply a container for a Java application. So, the point is, a Java application enhances the AWT / Swing / ... UI to gather certain information and then manage some "business logic".

Your only chance is: if this application is written in a reasonable way, then it should be written to branch the UI stuff from the actual business logic.

In other words: the user interface is requesting data; then call some other classes. And these other classes have nothing to do with UI things at all.

If this is true in your case, you can simply gather the required information yourself and insert it into these business logic classes.



But if this provider did a bad job, then the GUI and parts of the business logic are tightly coupled / confused. In this case, there are only three options:

  • you give up
  • you complain to your provider and ask them to redesign their design to come up with a solution that can be managed without their GUI app
  • you are trying to rebuild what their GUI does; and then you try to create your own "driver" based on this

Depending on your context, the effort for option 3 can be anything between "impossible" and "easy to do". And even when you manage to create such a job: your code is now tightly coupled with the delivery of that provider. Any change they can make could break your decision.

+2


source


Selenuim can do things like this.



You can also include it in a new project in eclipse and see if you can open the .class files (maybe you need a decompiler plugin) and if it's well designed enough and the GUI is decoupled from logic, be able to write for it command line tool

+2


source







All Articles