0

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

Gui
  • 51
  • 4
  • 7
  • it is not used by command prompt but from java.exe and it can handle both paths so it should be possible. – npocmaka Jun 09 '15 at 09:45
  • Along the same lines as npocmaka's comment - See http://stackoverflow.com/q/19762169/1012053. This question is almost a duplicate, in that CLASSPATH is a Java construct, and the linked Q&A discuss Java's support for `/`. – dbenham Jun 09 '15 at 11:05
  • See http://stackoverflow.com/q/10523708/1012053 for a general discussion of how CMD.EXE sometimes supports `/` as a folder delimiter. – dbenham Jun 09 '15 at 11:07

0 Answers0