简体   繁体   English

我们如何从单个Java类文件创建一个类的多个实例?

[英]How can we create more than one instance of a class from single Java class file?

I have a requirement which says I have to create only once class file of one Java Swing application and reuse them to create multiple instance of same application. 我有一个要求,要求我只创建一个Java Swing应用程序的类文件一次,然后重用它们来创建同一应用程序的多个实例。

One way comes to my mind is store this class file and create instances from that files whenever required. 我想到的一种方法是存储此类文件,并在需要时从该文件创建实例。

but is it correct way? 但这是正确的方法吗? Is there any other efficient way to create instance of applications using class created only once and stored somewhere? 还有其他有效的方法可以使用仅创建一次并存储在某个地方的类来创建应用程序实例吗?

Also there is additional desing constraint that says that you should use parts of class files in creating more than one application. 此外,还有其他的设计约束条件,要求您在创建多个应用程序时使用类文件的某些部分。

I have to create only once class file of one Java Swing application 我只需要创建一个Java Swing应用程序的类文件一次

compile the swing application's java source files into class files (this needs to be done just once) 将swing应用程序的Java源文件编译成类文件(这只需完成一次)

and reuse them to create multiple instance of same application. 并重用它们来创建同一应用程序的多个实例。

run the same class files in different virtual machines instances (sequentially, or simultaneously) 在不同的虚拟机实例中(顺序或同时)运行相同的类文件

.. or have I got you completely wrong? ..还是我让你完全错了? :) :)

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

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