QUESTION :
I must run a maven project from command line with this command and works fine:
mvn -Dexec.args="-classpath %classpath com.mycompany.serverrds.serverMainClass" -Dexec.executable="C:Program FilesJavajdk1.8.0_191binjava.exe" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
I create a .bat file to run the command quickly, but I get an error;
my .bat file is composed as:
@echo_off
cd c:xyz
"C:Program Filesapache-maven-3.6.0binmvn.cmd" -Dexec.args=-classpath %classpath com.mycompany.serverrds.serverMainClass -Dexec.executable="C:Program FilesJavajdk1.8.0_191binjava.exe"
where “c:devmavproj” is the directory where stay maven project, and the .bat file is named test.bat.
I receive this error: “the syntax of the command is incorrect”.
Well, i create new file .bat and I inserted only
"C:Program Filesapache-maven-3.6.0binmvn.cmd"
and the mvn command is executed ok.
The content of mvn.cmd :
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM -----------------------------------------------------------------------------
@REM Apache Maven Startup Script
@REM
@REM Environment Variable Prerequisites
@REM
@REM JAVA_HOME Must point at your Java Development Kit installation.
@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands.
@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed.
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files.
@REM -----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO%
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%mavenrc_pre.bat" call "%USERPROFILE%mavenrc_pre.bat"
if exist "%USERPROFILE%mavenrc_pre.cmd" call "%USERPROFILE%mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%"=="" goto OkJHome
for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i"
goto checkJCmd
:OkJHome
set "JAVACMD=%JAVA_HOME%binjava.exe"
:checkJCmd
if exist "%JAVACMD%" goto chkMHome
echo The JAVA_HOME environment variable is not defined correctly >&2
echo This environment variable is needed to run this program >&2
echo NB: JAVA_HOME should point to a JDK not a JRE >&2
goto error
:chkMHome
set "MAVEN_HOME=%~dp0.."
if not "%MAVEN_HOME%"=="" goto stripMHome
goto error
:stripMHome
if not "_%MAVEN_HOME:~-1%"=="_" goto checkMCmd
ANSWER :