• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

"_" in package name?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in our requirement we need to use underscore "_" character in our package name.
does anyone foresee any problems in using "_" in package name.
Thank.
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
it should compile...but it is just not common.
if you can live with that, then go ahead.
k
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There shouldn't be any problem in using the underscore in a package name since the underscore is an acceptable Java letter as per JLS 3.8 Identifiers, that is uppercase (A-Z) and lowercase (a-z) letters, underscore (_), dollar sign ($) and digits (0-9).
Moreover, we ain't got many rules 'round these parts, but we do got one. Please change your displayed name to comply with the JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Ravi Nal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by karl koch:
hi
it should compile...but it is just not common.
if you can live with that, then go ahead.
k



Dear k,
Thanks for ur reply.
i terribly pissedoff with "_" in my package name, but my management wants it.....so i'm looking for some good reasons so that i can survive without using "_" in my package name.
[ February 18, 2003: Message edited by: hiock ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could complain that your productivity suffers from contorting your hands to press that out-of-the way-and-difficult-to-find key (and with all of the subsequent backspacing required after pressing the '+' or the ')' right next to it). Plus, just imagine the injuries that your fingers might suffer from the strain.
You might be able to sabotage the convention by using two or even three sebsequent underscore characters in your package names (e.g., use package__name instead of package_name). Your co-workers will likely have a hard time trouble shooting the compiler errors.
[ February 19, 2003: Message edited by: Dirk Schreckmann ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just an FYI, 15 years after the fact.

I just came across an issue with the _ in a package name related to jar MANIFEST.MF and executable jars. Haven't found all the details of the why here but, we had a package name that included a package with underscores. When we built an executable jar the jar would not execute with the error 'ClassNotFoundException'



So, even though the language spec says the underscore is OK it still causes a problem with some run-time mechanisms.
 
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please supply more details. As you will see from the Java™ Tutorials, there are circumstances where you should have _s in package names, but maybe not between separate words. I am a bit surprised you are having problems.
 
Saloon Keeper
Posts: 14515
325
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The obvious question here is, do you have a typo in the main class entry of the manifest?
 
Marshal
Posts: 4018
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the package name segment remote_confg_proxy correct (missing the letter i in config)?
 
Rich Dammkoehler
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, the lack of an i is a mistake, but a consistent one. The manifest file also lacks the i in the name. I will admit that I fuzzed the names a bit to protect the source repo from which this comes which shortened the name considerably. The name also extends beyond the maximum 72 char width in a manifest file and therefore wraps. But I don't think the wrapping is the problem. When we took the underscores out everything worked fine.
 
Saloon Keeper
Posts: 26301
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't recall any specific instances, but I think that I've come across a few popular open-source libraries that had underscores in some of their package names. I might have even defined some myself.

Having said that, it's generally not encouraged, but should be legal unless you begin or end a package name component with an underscore (should be legal even there, but the convention is that such names are expected to be strictly language-internal).

Three possibilities exist:

1. You've got something coded that looks like an underscore but isn't. Commonly a problem when you use something like a word processor, where the editor may also automatically type in directional quote marks, em- and en-dashes and the like.

2. You've got upper-case letters in one or more package component names. Unix/linux are always sensitive to upper/lower case in filenames. Windows generally is not, but the Java code that processes File objects is, even under Windows.

3. The packages aren't actually located where you think they are and thus cannot be found in the classpath.
 
Rich Dammkoehler
Greenhorn
Posts: 3
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well darn.

So we went back to the commit that had the original problem and sure enough there was a spelling error in the pom.xml file that caused the manifest to be wrong. I'm truly embarrassed. Thought I'd found an issue, but I guess not. Underscores work just fine. Crazies case we tried while confirming what we thought we understood was this;



Sorry to have wasted folks time.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been using com._3chiles for years (you can't start with a numeral).
 
Rancher
Posts: 1043
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote: Unix/linux are always sensitive to upper/lower case in filenames.



I heard Linux supporting file systems like VFAT...
 
Campbell Ritchie
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rich Dammkoehler wrote:. . . Thought I'd found an issue, but I guess not. . . .

Sorry to have wasted folks time.

You had found an issue; it was simply different from what you thought it was. Well done finding it in the end .
 
Tim Holloway
Saloon Keeper
Posts: 26301
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Jozsef Balazs wrote:

Tim Holloway wrote: Unix/linux are always sensitive to upper/lower case in filenames.



I heard Linux supporting file systems like VFAT...



Indeed. Especially since I'm Nike-net transferring gcode files to my 3D printer via (VFAT32) thumb drives. And Linux tries to support NTFS, despite the fact that Microsoft hasn't always been transparent about how it works.

When Linux sees a VFAT file, it returns the upper/lower case in the file name exactly as it appears on the media. As far as opening a VFAT file for output using improper case, I'd have to check. I'm almost sure that if you re-open an existing file, variances between existing/actual case are normalized to the cases already on the media and otherwise the case is taken as supplied. Although DOS itself would have been quite happy to create 2 different files with the same name in different cases if you did it via certain channels. With unpredictable results when you tried to read it.

I spent a lot of time trying to remove a file named "PRT:" from an Windows NTFS disk once.
 
Ivan Jozsef Balazs
Rancher
Posts: 1043
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
And Linux tries to support NTFS, despite the fact that Microsoft hasn't always been transparent about how it works.



I saw on some Microsoft programming forums discussions on NTFS which were based on the Linux NTFS driver: it happened to be the available source for information.
 
Stephan van Hulst
Saloon Keeper
Posts: 14515
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stuff like that happens to everyone, Rich. :-)

Welcome to the Ranch by the way!
 
Tim Holloway
Saloon Keeper
Posts: 26301
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I've been using com._3chiles for years (you can't start with a numeral).



I avoid that. Partly because it's a systems convention, partly from working in languages where underscores aren't allowed to begin a name.

And partly because in my earliest professional days I worked with PL/1 on an IBM mainframe with a 48-character print chain. Where the underscores were deliberately mapped to print as blank characters. Meaning that sometimes reading a printed program listing could be ambiguous.

I've always used an "n" or "x" or something in front of names that start with digits.
 
Campbell Ritchie
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what Bear showed is the format recommended in the Java™ Tutorials.
 
Tim Holloway
Saloon Keeper
Posts: 26301
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:But what Bear showed is the format recommended in the Java™ Tutorials.



Well, I didn't write them now, did I?

Actually the one I really disagree with is where they mix JSTL and JSF on the same page.

My reasons for the naming syntax are mostly historical, although now that I think of it, it's also a bit easier when relaying information verbally to recite a name beginning with a letter than one starting with "underscore". Or to be precise, it's not any easier to say it, but it's less prone (in my experience) to be mis-interpreted by the listener.
 
Campbell Ritchie
Marshal
Posts: 76888
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:. . . Actually the one I really disagree with is where they mix JSTL and JSF on the same page. . . .

There are other mistakes in the Java™ Tutorials.
I spent a lot of time writing FORTH words with underscores attached e.g. +_; I pronounced them like this: “plus‑bar”.
 
Tim Holloway
Saloon Keeper
Posts: 26301
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My first PC was a Cromemco Z-80 system and I wrote my own Forth interpreter for it. It was fun to play with my sound card in Forth.

Never named anything with an underscore, but it was amusing to re-define "constants":

(returns 159)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic