billc.cn
billc.cn

Reputation: 7317

OS-independent way of specifying the class path

I have a bash script that bootstraps a Java process. I want it to be able to run on *nix and Cygwin. The problem is the separator in the -classpath parameter is different under the two platforms (: under *nix and ; under Windows).

I can't find an environment variable that specifies this separator (same as $PATH separator), so is there a better way to solve this than detecting the OS and hard-coding?

Upvotes: 1

Views: 55

Answers (1)

Neil Bartlett
Neil Bartlett

Reputation: 23948

No. If you write your bootstrap code in Java rather than Bash, you can use the path.separator system property.

Otherwise, it's quite normal to see separate launcher scripts for both Unix and Windows.

Upvotes: 3

Related Questions