aspose file tools*
The moose likes Beginning Java and the fly likes correct slash Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 1665
    
    7

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
Rancher

Joined: May 22, 2012
Posts: 865
    
    5
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: 1665
    
    7

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: 90
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: 7024
    
  16

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?
Artlicles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: correct slash
 
Similar Threads
an error
Print Problem...
Trouble in starting eclipse in Windows XP
Tomcat won't start
Maven Plugin for Eclipse Helios