English 中文(简体)
如何确保我的 Java 软件包名称是独一无二的?
原标题:How to *really* ensure my Java package names are unique?

避免 Java 软件包名称冲突的标准方式是使用 反向域公约 < code> com. [ mycomcorporates]. [rest- of- the-package-name] . 如果一个人拥有域名[ mycomcorporation].com.

然而,有几个开发商(或学生)个人:

  • Don t (or can t afford to) own a domain
  • Still conjure up some package names hoping they will be unique.

这本身就为一揽子冲突提供了范围。

此外,假设我拥有[我的公司].com。 是什么阻止开发者创建一个与我拥有相同的软件包前缀的图书馆并加以分发? AFAIK, 软件包名称方面没有法律约束力( “ 您必须拥有你在爪哇软件包中使用的域 ” )。 更别说开发者部分的这项行动可能不是有意的( 我们有多少人在我们命名软件包之前先梳理网络搜索一个不存在的域名? ) 。

更何况,即使我拥有一个域名,它也可能或可能不适合作为包件名使用(我的域名可包括连字符,或者可能很长,尽管它是一个合法的一揽子名称,但它仍然可能使它不切实际)。

所以,我的问题是: 我如何真正使我的 Java 软件包名独一?

最佳回答

您无法绝对保证您的软件包名称将具有全球独特性。 正如您所提到的, 没有任何东西能阻止其他人使用相同的软件包名称, 不论是谁拥有软件包名称所基于的软件包名称。 没有正在使用的软件包名称的权威索引 。

问题回答

我看到你的问题有两个答案:

  • Make your student project a SourceForge project and name packages net.sf.myproject (or use any similar free host, such as GitHub). Such a package name is likely not to be used by others, although there is no guarantee as Matt Hurne points out
  • Other than that, if you can t or don t want to afford a domain, your program is unlikely to be used by a wide audience anyway, and you can name your packages whatever you want




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签