This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes correct slash Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "correct slash" Watch "correct slash" New topic
Author

correct slash

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

I read that in windows backslash is used to make classpath while in unix forward slash but for my windowxp both are working.

C:\WINDOWS\system32>java -cp F:\Music\Audio Hello
hello

C:\WINDOWS\system32>java -cp F:/Music/Audio Hello
hello


OCA7
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1409

It depends on which character(s) an operating system recognizes as a file separator.
See this wikipedia article.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Ivan Jozsef Balazs
Ranch Hand

Joined: May 22, 2012
Posts: 380
Jelle Klap wrote:It depends on which character(s) an operating system recognizes as a file separator.


It also might depend on the various programs.

This does not work for me on Windows from the command shell, because dir seems to take / for the beginning on option:
dir build/WEB-INF

This however does:
dir build\WEB-INF

Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1409

Yes, that's why the wikipedia article I linked to specifies the OS and Shell contexts.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Ivan Jozsef Balazs wrote:
Jelle Klap wrote:It depends on which character(s) an operating system recognizes as a file separator.


It also might depend on the various programs.

This does not work for me on Windows from the command shell, because dir seems to take / for the beginning on option:
dir build/WEB-INF

This however does:
dir build\WEB-INF



It works for classpath not for dir command.
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 88
ankita modi. wrote:It works for classpath not for dir command.


In addition, Unix based operating systems use / for file separators, while Windows uses \.

Unix based uses : for token separator while Windows uses ;.

It looks like javac in your case can work with / or \

You can also install Cygwin (http://www.cygwin.com) on a Windows machine which provides a Unix style environment.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 4750
    
    7

ankita modi. wrote:I read that in windows backslash is used to make classpath while in unix forward slash but for my windowxp both are working.

I suspect that it may have to do with the fact that the 'java' command uses Java conventions; and in Java '/' is recognised as a file (or, more correctly, a directory or path) separator in the right context. For example, the java.io.File class accepts '/' as a path separator regardless of what system the program is running on.

My question is: when will Microsoft get around to accepting what pretty much the rest of the computer world already uses?
Answer: probably never; and I'm certainly not going to hold my breath waiting.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: correct slash
 
Similar Threads
Trouble in starting eclipse in Windows XP
Tomcat won't start
Print Problem...
Maven Plugin for Eclipse Helios
an error