在netbeans中创建具有多个主类的jar [英] Creating jars with multiple main classes in netbeans

查看:137
本文介绍了在netbeans中创建具有多个主类的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用netbeans IDE在java中创建VoIP客户端服务器对。我想只使用一个项目,但我不熟悉netbeans如何创建Jar文件。我需要一个如果这是可能的,如果是的话,如何设置它。

I'm am creating a VoIP client server pair in java using the netbeans IDE. I would like to use only 1 project but I am unfamiliar with with how netbeans would create the Jar file. I need a to if this is possible and if so, how to set it up.

推荐答案

我认为'主类'的目的意味着最终的JAR'清单文件,将一个类标记为'要运行的类':以便最终用户只需双击它*或运行简化的命令行,如:

I believe the purpose of a 'main class' means that the eventual JAR' manifest file, will label one class as being the 'class to run': so that the end-user can just double-click it* or run a simplified commandline like:

java - jar< jar>

而不是必须指定整个包/类名,如:

rather than having to specify the whole package/class name like:

java -cp <jar> com.yourcom.package.classname

如果我是对的,那么我看不出它是怎么回事拥有多个主要课程会有意义吗?
也许我误解了你的问题 - 或者'主'类还有其他目的吗?

If I'm right, then I don't see how it would make sense to have more than one main class ? Maybe I misunderstod your question - or there is another purpose to the 'main' class?

如果你的意思是有两个类有'主'方法 - 那么这很好 - 最终用户可以按名称启动任何类 - 只要他们有标准的主方法sig,例如:

If you mean having two classes which have a 'main' method - then this is fine - the end user can launch any of the classes by name - and so long as they have the standard main method sig, for instance:

public static void main(String[] args)

它应该正常工作。

*(至少在Windows上,这是否有效还取决于他们拥有哪些JRE以及其他东西)

*(on Windows at least, and whether that works also depends on which JRE they have and probably other things)

这篇关于在netbeans中创建具有多个主类的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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