0

I have an application that is developed in Java that has nice GUI and all. I don't have the source code and also the dll's of that. But I have the compiled classes of that application (.jar files).

Now, I want to automate that application. I mean the application needs manual intervention.

Can I use that compiled classes so that I can use its functions to automate the functionality of that application?

If so, how would this be done?

4

3 回答 3

2

您不必“从该应用程序 (.jar) 中获取已编译的类”。一个更好的主意是像对待任何其他 3rd 方 JAR 一样对待它,并在编译和运行时将其添加到您的 CLASSPATH 中。

您将编写自己的类来实例化该第 3 方类的实例并调用其方法,就像您从 JDK 获得的任何类一样。

您可能无法更改该类;即使可以,您也可能不想。

如果您必须拥有新功能,OO 方式会建议您应该扩展该类,如果可以的话,并根据您的需要覆盖它的方法。

于 2012-07-17T13:49:59.307 回答
1

将其.jar放入您的类路径并使用该应用程序中您想要的任何内容。如果您需要使用私有字段或方法,您也可以使用反射 API。使用文件中的对象没有限制.jar

于 2012-07-17T13:51:57.367 回答
0

如果您所指的应用程序是专有的,您应该小心侵犯任何版权。否则,任何 java 反编译器都会从这些类文件中获取源代码。

于 2012-07-17T13:49:54.087 回答