Can I use \ and / to be directory delimiter in CLASSPATH of .bat

1.3k views Asked by At

I have a .bat file for running on Window (I am using Window 7)

Following is its context:

@echo off
set CLASSPATH=.;./lib/textutils.jar;.\lib\hellotool.jar;.\main.jar
echo %CLASSPATH%
java me.Hello

Please see the second line : set CLASSPATH=.;./lib/textutils.jar;.\lib\hellotool.jar;.\main.jar

It contains both "/" and "\" in CLASSPATH.

The text "./lib/textutils.jar" is created by other script and its use "/" as directory delimiter, others are created manually by myself.

The code can run and jars are loaded normally.

However, I am not sure about the syntax.

I know that:

  • Windows and MS-DOS uses "\" (backslash) for directory delimiter and use ";" (semi-colon) as path separator.

For example:

C:\a.jar;C:\b.jar
  • Linux and Mac uses "/" (forward slash) for directory delimiter and use ":" (colon) as path separator.

For example:

/User/a.jar:/User/b.jar

So, for my bat file:

Is it really correct?

Why "./lib/textutils.jar" can be loaded with "/" separator?

Is there any problem in future or in other Window version?

Should I change "./lib/textutils.jar" to ".\lib\textutils.jar"?

See sample for more details.

Thank you in advance

0

There are 0 answers