• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Do --class-path and --module-path command line options always use ; as the separator?

 
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been running on Windows for too many months in a row to remember now.

I noticed here:
https://docs.oracle.com/javase/10/tools/java.htm#JSWOR624

That it seems regardless of platform, the --class-path, --module-path options and their ilk all use ; as the separators, regardless of platform?

Does that apply to the setting of environment variables for these as well?

I'd forgotten this if it was always the case.  I guess it makes them portable in syntax, if not in actual values you'd have for them anyway.
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interestingly, the Sybex book goes out of there way right at the beginning to inform you that you should use : separators everywhere except Windows, that stuck in my brain until I saw the linked authoritative-looking reference which threw an NotWhatIRememberedException in my mind.
 
Saloon Keeper
Posts: 24314
167
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
In the Unix™ operating system, including MacOS and Linux - and of course, Sun's Solaris, where Java was first developed, the semicolon is parsed by most command-line shells as a command separator.

That is, the sequence:

is equivalent to

Thus, to avoid annoying the command shell, Java implementations on Unix and Unix-like OS's use the colon character to separate items on a command line where a comma cannot suffice.

Conversely, you can get into trouble on Windows using the colon character, since it's a common feature in Windows filesystems paths:

That's why the difference in conventions exists. Not strictly because of Java, but because of the command-shell parsers that execute Java.
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim, that is super-clear and another important basic difference between Linux/Unix and Windows.

That doesn't seem to explain what I read at the link I provided, however, which seems to imply in a non-Windows-Specific document that apparently applies to everyone on all platforms, that those options are going to be fine with ;'s in them.

Is this because they expect the values in question to be quoted like I dunno, '/usr/tim/jars;~java' or some such, so that the ; is seen only by the Java tools and not the shell and thus rendered harmless?

Or am I instead taking it too literally, because where they write ';-delimited' actually means ':-delimited' when we are on Linux or Unix?

I'm reminded of the recent dust-up over '/' vs. '\\' in Java source code, where we seemed to disagree over whether there was ever a Good Reason to eschew '/' in favor of '\\' while working on Windows, or Java helpfully took care of that problem by writing us lots of code once.

I detest space bars in any directory or file name, and consider them anathema.  Other people are like "Relax dude, that's why we quote everything!  Just chill!"

So are they saying ';-delimited' on that page because they expect the values to be protected by 'quotes;or' 'i;/am/just;taking/them/;too/literally' ?

 
Tim Holloway
Saloon Keeper
Posts: 24314
167
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 think that the document in question may be defective. I've always used colons and I haven't done Java in Windows for an æon.

Certainly you'd have to quote stuff all over the place if you used semi-colons in a Unix-like OS the way they say to. Assuming it even works (I haven't checked).
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fair enough.  The question is still unresolved.

Just so we aren't pointing to an out-of-date, no-longer-relevant page, I will mention that the current latest LTS tools documentation is essentially unchanged on these points, at:
https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I think that the document in question may be defective. I've always used colons and I haven't done Java in Windows for an æon.



+1 for using the word  æon.
 
Tim Holloway
Saloon Keeper
Posts: 24314
167
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

Jesse Silverman wrote:Fair enough.  The question is still unresolved.

Just so we aren't pointing to an out-of-date, no-longer-relevant page, I will mention that the current latest LTS tools documentation is essentially unchanged on these points, at:
https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html



I think you vastly under-estimate how often Oracle does maintenance to those pages and especially at the macro level.

But the colon/semicolon issue dates all the way back to primordial Java. It's determined by the requirements of the OS shell in question and while Unix shells in particular come and go, they do tend to have certain common characteristics for their OS.
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Watching an actual Oracle presentation on Java 9 modules, of course he uses : as the separator in his examples...

I will try not to read too much into why that seminal documentation exclusively says semi-colons in it.

I won't lose sleep, but it would be interesting to learn whether it was intentional or an oversight that has persisted for years.
 
Tim Holloway
Saloon Keeper
Posts: 24314
167
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
My best guess is that somewhere a Windows person got hold of the docs before it said anything explicit about separators, made a cursory note about Unix, then proceeded to add detailed document Windows-style and forgot to finish the Unix notes. Either that, or you've somehow managed to target a Windows version of the docs that doesn't make it plain that it's the Windows version.

I just ran Java "help". It says "colons" where the online file you're looking at says "semicolons" with 2 exceptions: -XX:OnError and -XX:OnOutOfMemoryError, both of which "Sets a custom command or a series of semicolon-separated commands to run". That's in keeping with Unix shell usage, since the commands in questions are actual system commands, not Java functions. And yes, they have to be quoted.

In another place "you should enclose the arguments in quotation marks, because otherwise the shell treats the semicolon as command end."

I would expect/hope that the Windows version reflects Windows constraints similarly.
 
Jesse Silverman
Saloon Keeper
Posts: 1306
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not that it is super-important, but I note that on Windows systems where people have switched over to PowerShell as their go-to command line, ; also separates commands, so I wind up using 'mods/;/my/otherdir/' quoted anyway!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic