title: Start Tomcat from user
body: <p>I have one problem!
  I need to start web-application in Tomcat from 'user' but Tomcat start from command line (not start as service).
  I have catalina.bat file for command line: </p>
  
  <blockquote>
  <pre><code>set CATALINA_OPTS=-server -Xmx1000m -Xms1000m -Xmn384m -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:MaxPermSize=192m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.library.path=D:\dev\bin\apache-tomcat-6.0.16\bin
  
  rem Guess CATALINA_HOME if not defined
  set CURRENT_DIR=%cd%
  if not "%CATALINA_HOME%" == "" goto gotHome
  set CATALINA_HOME=%CURRENT_DIR%
  if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  cd ..
  set CATALINA_HOME=%cd%
  cd %CURRENT_DIR%
  :gotHome
  if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  echo The CATALINA_HOME environment variable is not defined correctly
  echo This environment variable is needed to run this program
  goto end
  :okHome
  
  rem Get standard environment variables
  if "%CATALINA_BASE%" == "" goto gotSetenvHome
  if exist "%CATALINA_BASE%\bin\setenv.bat" call "%CATALINA_BASE%\bin\setenv.bat"
  goto gotSetenvBase
  :gotSetenvHome
  if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
  :gotSetenvBase
  
  rem Get standard Java environment variables
  if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath
  echo Cannot find %CATALINA_HOME%\bin\setclasspath.bat
  echo This file is needed to run this program
  goto end
  :okSetclasspath
  set BASEDIR=%CATALINA_HOME%
  call "%CATALINA_HOME%\bin\setclasspath.bat" %1
  if errorlevel 1 goto end
  
  rem Add on extra jar files to CLASSPATH
  if "%JSSE_HOME%" == "" goto noJsse
  set CLASSPATH=%CLASSPATH%;%JSSE_HOME%\lib\jcert.jar;%JSSE_HOME%\lib\jnet.jar;%JSSE_HOME%\lib\jsse.jar
  :noJsse
  set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\bootstrap.jar
  
  if not "%CATALINA_BASE%" == "" goto gotBase
  set CATALINA_BASE=%CATALINA_HOME%
  :gotBase
  
  if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir
  set CATALINA_TMPDIR=%CATALINA_BASE%\temp
  :gotTmpdir
  
  if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuli
  set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
  :noJuli
  
  rem ----- Execute The Requested Command ---------------------------------------
  
  echo Using CATALINA_BASE:   %CATALINA_BASE%
  echo Using CATALINA_HOME:   %CATALINA_HOME%
  echo Using CATALINA_TMPDIR: %CATALINA_TMPDIR%
  if ""%1"" == ""debug"" goto use_jdk
  echo Using JRE_HOME:        %JRE_HOME%
  goto java_dir_displayed
  :use_jdk
  echo Using JAVA_HOME:       %JAVA_HOME%
  :java_dir_displayed
  
  set _EXECJAVA=%_RUNJAVA%
  set MAINCLASS=org.apache.catalina.startup.Bootstrap
  set ACTION=start
  set SECURITY_POLICY_FILE=
  set DEBUG_OPTS=
  set JPDA=
  
  if not ""%1"" == ""jpda"" goto noJpda
  set JPDA=jpda
  if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
  set JPDA_TRANSPORT=dt_shmem
  :gotJpdaTransport
  if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
  set JPDA_ADDRESS=jdbconn
  :gotJpdaAddress
  if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend
  set JPDA_SUSPEND=n
  :gotJpdaSuspend
  if not "%JPDA_OPTS%" == "" goto gotJpdaOpts
  set JPDA_OPTS=-Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND%
  :gotJpdaOpts
  shift
  :noJpda
  
  if ""%1"" == ""debug"" goto doDebug
  if ""%1"" == ""run"" goto doRun
  if ""%1"" == ""start"" goto doStart
  if ""%1"" == ""stop"" goto doStop
  if ""%1"" == ""version"" goto doVersion
  
  echo Usage:  catalina ( commands ... )
  echo commands:
  echo   debug             Start Catalina in a debugger
  echo   debug -security   Debug Catalina with a security manager
  echo   jpda start        Start Catalina under JPDA debugger
  echo   run               Start Catalina in the current window
  echo   run -security     Start in the current window with security manager
  echo   start             Start Catalina in a separate window
  echo   start -security   Start in a separate window with security manager
  echo   stop              Stop Catalina
  echo   version           What version of tomcat are you running?
  goto end
  
  :doDebug
  shift
  set _EXECJAVA=%_RUNJDB%
  set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java"
  if not ""%1"" == ""-security"" goto execCmd
  shift
  echo Using Security Manager
  set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
  goto execCmd
  
  :doRun
  shift
  if not ""%1"" == ""-security"" goto execCmd
  shift
  echo Using Security Manager
  set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
  goto execCmd
  
  :doStart
  shift
  if not "%OS%" == "Windows_NT" goto noTitle
  set _EXECJAVA=start "Tomcat" %_RUNJAVA%
  goto gotTitle
  :noTitle
  set _EXECJAVA=start %_RUNJAVA%
  :gotTitle
  if not ""%1"" == ""-security"" goto execCmd
  shift
  echo Using Security Manager
  set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
  goto execCmd
  
  :doStop
  shift
  set ACTION=stop
  set CATALINA_OPTS=
  goto execCmd
  
  :doVersion
  %_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo
  goto end
  
  
  :execCmd
  rem Get remaining unshifted command line arguments and save them in the
  set CMD_LINE_ARGS=
  :setArgs
  if ""%1""=="""" goto doneSetArgs
  set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  shift
  goto setArgs
  :doneSetArgs
  
  rem Execute Java with the applicable properties
  if not "%JPDA%" == "" goto doJpda
  if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
  echo  %JAVA_OPTS%
  %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  goto end
  :doSecurity
  %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  goto end
  :doJpda
  if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
  %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  goto end
  :doSecurityJpda
  %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
  goto end
  
  :end
  </code></pre>
  </blockquote>
  
  <p>Question: How I can start Tomcat from 'user' via command line with catalina.bat ??
  P.S. I have a Windows Server</p>