我可以/应该用 & 符号命名 Java 项目吗?

发布于 2024-08-23 11:26:59 字数 209 浏览 3 评论 0原文

我正在为通常用& 符号引用的概念/构造创建一个新的Java 项目(例如PB&J)。这样命名项目可以吗?我应该避免它吗? Java 项目名称中是否存在不允许出现的符号?是否有一些通常避免使用的符号? Java 项目命名约定中的符号来自哪里?

编辑:抱歉造成误解。它实际上不是一个 Java 项目,而是一个 Eclipse Java 项目。

I'm creating a new Java project for a concept/construct that's usually referred to with an ampersand (e.g. PB&J). Is it ok to name the project that? Should I avoid it? Are there any symbols that are not allowed in Java project names? Are there any symbols that are generally avoided? Where do symbols come in with regard to Java project naming conventions?

Edit: Sorry for the misunderstanding. It's not a Java project really, it's an Eclipse Java project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

杀手六號 2024-08-30 11:26:59

Java本身没有“项目”的概念。您可能指的是像 Eclipse 这样的 IDE。他们也许能够使用特殊字符,例如“&”在项目名称中,但恕我直言,您确实应该避免使用它们。这会带来更多的麻烦,而不是其价值。

另一个应该避免的字符是“!”,因为它在 Java 中对于指向 JAR 文件中资源的 URL 有特殊含义。

Java itself does not have the notion of "project". What you probably are referring to are IDEs like Eclipse. They might be able to use special characters like "&" in project names, but imho you really should avoid using them. It will make more trouble than it's worth.

Another character which should be avoided is "!", as it has a special meaning within Java for URLs pointing to resources within JAR Files.

林空鹿饮溪 2024-08-30 11:26:59

据我了解,java-project 是 IDE 的术语,而不是 java 术语。这就是为什么我认为是的,你可以。

As I understand java-project is term of your IDE but not a java term. That's why I think yes, you can.

逆夏时光 2024-08-30 11:26:59

特殊字符,例如 &即使它们看起来是“允许的”,确实应该避免。它们确实会在以后引起一些不幸的副作用,并且可能很难追查为什么某些事情不能正常工作。

在一个不相关的例子中,我有时会看到有人在文件名中使用空格,这些文件在 Windows 机器上工作正常,但在上传到网络时突然中断,因为平台上不完全支持空格等。

所以这是一个安全问题,而不是抱歉的问题。

Special characters such as & really should be avoided even if they appear to be "allowed". They do cause some unfortunate side effects later on and may be difficult to track down why certain things are not working as they should.

In an unrelated example I sometimes see persons using spaces in the names of files which work fine on Windows machines then suddenly break when uploaded to the web because spaces are not fully supported on the platform etc etc.

So its a matter of rather safe than sorry.

傲性难收 2024-08-30 11:26:59

如果“&”符号最终出现在文件名中,那么它就特别糟糕。在大多数 Unix shell 中,不带引号的 & 符号意味着“在后台运行一切直到 & 符号”。结果出现了令人困惑的错误。

正确的文件名引用可以解决此类问题,但人们不可避免地会忘记一组引号,从而导致事情崩溃。

坚持使用字母、数字、连字符、下划线和句点。

Ampersand is especially bad if it might end up in a file name. In most Unix shells, an unquoted ampersand means "run everything up to the ampersand in the background". Baffling bugs result.

Proper filename quoting fixes problems like this, but people inevitably forget a set of quotes and things blow up.

Stick to letters, digits, hypen, underscore, and period.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文