使NetBeans(ant)为一个项目生成多个jar文件 [英] Make NetBeans(ant) generate multiple jar files for one project

查看:95
本文介绍了使NetBeans(ant)为一个项目生成多个jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个netbeans项目,包括两个主要类,一个启动客户端,另一个启动服务器。

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

我需要创建两个jar文件来包装两个exe文件,一个用于客户端,一个用于服务器,我该怎么做?

I need to create two jar file to wrap into two exe file, one for client and one for server, how can i do this?

谢谢。

注意:即时通讯使用蚂蚁。

NB: im using ant.

推荐答案

您有两种选择:

首先,您可以在项目的build.xml中覆盖NetBeans ant目标,以便创建两个jar文件。

如何执行此操作,NetBeans的在线帮助中对此进行了解释。本章名为自定义IDE生成的Ant脚本

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".

很可能服务器和客户端正在使用一些通用代码,因此您最终将使用NetBeans中的三个不同项目:

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


  1. MyApp Common - 包含服务器和客户端使用的所有类

  2. MyApp Server - 包含服务器所需的一切,包括项目MyApp Common作为库

  3. MyApp客户端 - 包含客户端所需的一切,包括项目MyApp Common作为库。

然后在构建客户端或服务器项目时,每个项目都会生成一个单独的jar文件。

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

这篇关于使NetBeans(ant)为一个项目生成多个jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆