开发者

Make NetBeans(ant) generate multiple jar files for one project

开发者 https://www.devze.com 2023-02-06 07:32 出处:网络
i have a project in netbeans that include two main classes, one starts a client and other starts a server.

i have a project in netbeans that include two main classes, one starts a client and other starts a server.

I need to create two jar file to wrap i开发者_运维知识库nto two exe file, one for client and one for server, how can i do this?

Thanks.

NB: im using ant.


You have two options:

First, you can overwrite the NetBeans ant target in the project's build.xml in order to create your two jar files.
How you can do this, is explained in the online help of NetBeans. The chapter is named "Customizing the IDE-Generated Ant Script

But I would recommend to create different projects for each "executable".

Most probably server and client are using some common code, so you'll wind up with three different projects in NetBeans:

  1. MyApp Common - contains all classes that are used by server and client
  2. MyApp Server - contains everything that you need for the server, includes the project "MyApp Common" as a library
  3. MyApp Client - contains everything that you need for the client, includes the project "MyApp Common" as a library.

Then when you build the client or server project, each will generate a separate jar file.


You can have two mains in the same jar file. (Only one if you want an executable jar)

To create two jars you need two maven modules/pom.xml

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号