views:

93

answers:

4

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.

+3  A: 

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.

mhaller
+1  A: 

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

Roman
+1  A: 

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.

Vincent Ramdhanie
+1  A: 

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.

Daniel Newby
Also, URLs and HTML in general.
Christoffer Hammarström