In order to compile an application I can do: (I am on Windows)
javac name\mihaiu\test\CTest.java
javac name/mihaiu/test/CTest.java
I believe this works cause Windows is trying to be nice and helpful. I
think it's replacing the "/" with "\" cause Windows uses the backslashes
natively. I'm not 100% sure, but I think Linux wouldn't be as friendly.
OH, don't get me wrong, friendly doesn't necessarily equal
better/good/preferred. By no means! As you can see this flexibility
results in ambiguity and confusion which is never good. So, for linux's
complexity, it's unambiguous and exact, resulting in no problems (hopefully!
:>).
but when I run it I must do:
java name/mihaiu/test/CTest
Yup, cause now, you're running the java.exe program passing in the
name/mihaiu/test/CTest as an application parameter/argument. Therefore
Windows runs the java.exe program, and passes your argument to the program,
where the java.exe will interpret the slashes. Java won't be as nice for
you as Windows was. It helps to think of where you are running things.
Windows runs the java.exe program, then once java.exe is up and running,
it's passed the arguments you typed out, and then it's in control of them,
which is why the right slashes are required, no ambiguity. I get caught on
this all the time too. :<
The backslashes won't work even if I am on a windows platform
! Why is this happening ? On windows the backslash is the separator.
Yup the backslash is the path separator, but it's Windows trying to help you
out. For example, try swapping the slashes in your URLs in IE, both will
work. That's Billy Boy trying to help you out. I'm not sure what Netscape
does. Java is meant to be more straight forward, is a programming language
not an OS and therefore needs to be more exactly. Also, Java was developed
by a unix company (SUN, well, ok, a Solaris UNIX company, but it's not MS
:>) and therefore you'll find a lot of UNIX oriented "things" that are
ported over to Windows to make them cross platform.
But then again, I'm only on my first cup of coffee this am and I could be
all wrong. :>
Good luck! :>