开发者

converting a batch file to a shell script

开发者 https://www.devze.com 2023-02-28 08:14 出处:网络
Can anyone please help me with this? I\'ve got a .jar file for which I wrote a batch file (code is shown below). How do I create an equivalent shel开发者_JAVA技巧l script?

Can anyone please help me with this? I've got a .jar file for which I wrote a batch file (code is shown below). How do I create an equivalent shel开发者_JAVA技巧l script?

SETLOCAL ENABLEDELAYEDEXPANSION
    set BUILD_LIB_DIR=lib
    set CLASSPATH=.
    for %%f in (%BUILD_LIB_DIR%\*.jar)do set CLASSPATH=!CLASSPATH!;%%f
    java -client -cp %CLASSPATH% -jar -Dport=7000 MyJar.jar
ENDLOCAL

Thanks


I'm not familiar with scripting on Windows (I infer you are using Windows from the backslash.), but I thought I'd offer the following anyway. This should work on a Unix/Linux workalike system. It is a bash script.

Create script file with following content and make it executable:

#!/bin/bash

BUILD_LIB_DIR=lib
CLASSPATH=.
for f in $BUILD_LIB_DIR/*.jar; do
    CLASSPATH="$CLASSPATH;$f"
done
java -client -cp $CLASSPATH -jar -Dport=7000 MyJar.jar
0

精彩评论

暂无评论...
验证码 换一张
取 消