3

I have the following bat script:

@echo off set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_32 set JRE_HOME=C:\Program Files\Java\jdk1.6.0_32\jre set Path=%JAVA_HOME%\bin;%Path% cd C:\project mvn validate compile package db-migration:migrate -DskipTests REM script exits here, the second line never been executed java -jar target/compiled_tar.jar 

The last line never been executed. The "mvn..." is successfully done, the compiled_tar.jar is created, the output is:

[INFO] BUILD SUCCESS 

If I insert the PAUSE command between last and previous lines the PAUSE also never been occurred. Why?

4

2 Answers 2

12

mvn is itself a .bat file, so (for compatibility with MS-DOS 1.0) Windows will stop executing your batch file. To fix this, use the call command:

call mvn validate compile package db-migration:migrate -DskipTests 
Sign up to request clarification or add additional context in comments.

3 Comments

You have changed my life. Thanks!
The year is 2013 and I have to care about how MS-DOS 1.0 functioned 32 years ago. I don't know whether I should be sad or impressed.
@ChrisNielsen 2019 now.
0

Using this Maven command (set maven_batch_pause=on) will solve this perfectly:

@echo off set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_32 set JRE_HOME=C:\Program Files\Java\jdk1.6.0_32\jre set Path=%JAVA_HOME%\bin;%Path% set maven_batch_pause=on cd C:\project mvn validate compile package db-migration:migrate -DskipTests REM The script exits here, and the second line will never be executed java -jar target/compiled_tar.jar 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.