简体   繁体   English

在另一个 Java 应用程序的面板中运行 Java 应用程序(JAR 文件)

[英]Running a Java application (JAR file) in a panel of another Java application

有没有办法在另一个 Java 应用程序( b.jar的 GUI)的 GUI 中运行 Java 应用程序( a.jar )?

Your question is a specific example of the more general question:您的问题是更一般问题的具体示例:

Can I access and use an object from one Jar file in another Jar file.我可以在另一个 Jar 文件中访问和使用一个 Jar 文件中的对象吗?

Yes this is possible and in fact is done all the time, but the applications must be set up to allow this, ie,是的,这是可能的,实际上一直在进行,但必须设置应用程序以允许这样做,即,

  • If the JPanel of interest is obtainable in a public way, either through a public variable (bad) or a public getter method or constructor.如果感兴趣的 JPanel 可以通过公共变量(坏)或公共 getter 方法或构造函数以公共方式获得。
  • Then the jar file of interest needs to be in the class path of the class that needs it.然后感兴趣的jar文件需要在需要它的类的类路径中。 If you're using an IDE like Eclipse or NetBeans, then the IDE must be configured so that the jar file is in the build path.如果您使用 Eclipse 或 NetBeans 等 IDE,则必须配置 IDE,以便 jar 文件位于构建路径中。
  • And you'll need to import the appropriate classes with their full package name, call appropriate constructors and methods, etc...并且您需要使用完整的包名导入适当的类,调用适当的构造函数和方法等...
  • As with most coding questions, the devil's almost always in the details, so if you're still stuck, please give us some more information and code, and we'll see if we can give you more specific answers.与大多数编码问题一样,魔鬼几乎总是在细节中,所以如果你仍然被卡住,请给我们一些更多的信息和代码,我们会看看我们是否可以给你更具体的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM