BASH to BATCH java

There's this BASH file:

set -eu
DIR=`dirname $0`
java $HEAP_SIZE -cp $CLASSPATH something.something2 "$@"

That I want to turn into a .bat file to run on windows This is what I have so far:

set DIR = %cd%
set JAR = DIR/myjar.jar
set CLASSPATH = %JAR%:./
set HEAP_SIZE = -size
java %HEAP_SIZE% -cp %CLASSPATH% something.something2

How would I complete it to have the same behavior as the bash file?


%CD% can work, but your bash script seems to be setting the directory based off the path of the script (i.e., argument in $0) and not the current directory. To use the same directory as the batch file, you use %~dp0.

You missed % around your DIR variable when you wanted to expand the value.

You shouldn't have spaces around equal signs in your set statements.

The equivalent of $@ in batch is %*.

You should quote your %CLASSPATH%. On Windows you are much more likely to encounter paths with spaces in them.

set "DIR=%~dp0"
set "JAR=%DIR%/myjar.jar"
set "CLASSPATH=%JAR%:./"
set "HEAP_SIZE=-size"
java %HEAP_SIZE% -cp "%CLASSPATH%" something.something2 %*

Need Your Help

Can't overwrite standard icons of jquery mobile search/filter field in android browser and emulator

jquery search mobile icons field

I wanted to replace jquery mobile's standard icons in the frameworks list view search field (when set: data-filter="true") with android specific icons. I found the responsible selector and overwrot...

NOT to soft delete a row in a table that contain foreign key to other tables

sql sql-server sql-server-2008

I am doing soft delete in all my tables. I should not soft delete a row when that ID is referred in other tables. Also, when the referred child table is deleted i.e, Isdeleted = 1, then I should be...