zoukankan      html  css  js  c++  java
  • Tomcat启动脚本(3)setclasspath.bat

    @echo off
    rem Licensed to the Apache Software Foundation (ASF) under one or more
    rem contributor license agreements.  See the NOTICE file distributed with
    rem this work for additional information regarding copyright ownership.
    rem The ASF licenses this file to You under the Apache License, Version 2.0
    rem (the "License"); you may not use this file except in compliance with
    rem 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, software
    rem distributed under the License is distributed on an "AS IS" BASIS,
    rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    rem See the License for the specific language governing permissions and
    rem limitations under the License.
    
    rem ---------------------------------------------------------------------------
    rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
    rem are valid and consistent with the selected start-up options and set up the
    rem endorsed directory.
    rem ---------------------------------------------------------------------------
    
    rem Make sure prerequisite environment variables are set
    
    rem In debug mode we need a real JDK (JAVA_HOME)
    rem startup.bat启动的话,%1是start,往下执行
    if ""%1"" == ""debug"" goto needJavaHome
    
    rem Otherwise either JRE or JDK are fine
    rem JRE_HOME未设置,往下执行
    if not "%JRE_HOME%" == "" goto gotJreHome
    rem JAVA_HOME设置了跳到gotJavaHome
    if not "%JAVA_HOME%" == "" goto gotJavaHome
    echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    echo At least one of these environment variable is needed to run this program
    goto exit
    
    :needJavaHome
    rem Check if we have a usable JDK
    if "%JAVA_HOME%" == "" goto noJavaHome
    if not exist "%JAVA_HOME%injava.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injavaw.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injdb.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injavac.exe" goto noJavaHome
    set "JRE_HOME=%JAVA_HOME%"
    goto okJava
    
    :noJavaHome
    echo The JAVA_HOME environment variable is not defined correctly.
    echo It is needed to run this program in debug mode.
    echo NB: JAVA_HOME should point to a JDK not a JRE.
    goto exit
    
    rem 设置JRE_HOME为java_home
    :gotJavaHome
    rem No JRE given, use JAVA_HOME as JRE_HOME
    set "JRE_HOME=%JAVA_HOME%"
    
    rem 如果设置了jre_home环境变量就取jre_home下的java.exe和javaw.exe,否则取java_home下的
    :gotJreHome
    rem Check if we have a usable JRE
    if not exist "%JRE_HOME%injava.exe" goto noJreHome
    if not exist "%JRE_HOME%injavaw.exe" goto noJreHome
    goto okJava
    
    :noJreHome
    rem Needed at least a JRE
    echo The JRE_HOME environment variable is not defined correctly
    echo This environment variable is needed to run this program
    goto exit
    
    :okJava
    rem Don't override the endorsed dir if the user has set it previously
    rem 如果设置了环境变量JAVA_ENDORSED_DIRS就跳转,但是一般不设置,往下。Java9已经不支持该环境变量了。
    if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir
    rem Java 9 no longer supports the java.endorsed.dirs
    rem system property. Only try to use it if
    rem CATALINA_HOME/endorsed exists.
    rem 不存在,所以跳转到gotEndorseddir
    if not exist "%CATALINA_HOME%endorsed" goto gotEndorseddir
    set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%endorsed"
    :gotEndorseddir
    
    rem Don't override _RUNJAVA if the user has set it previously
    rem previously 事先
    rem 如果设置了_RUNJAVA环境变量就跳转,但是一般不设置,往下走,将JRE_HOMEinjava.exe设置为_RUNJAVA,这里的JRE_HOME是JAVA_HOME
    if not "%_RUNJAVA%" == "" goto gotRunJava
    rem Set standard command for invoking Java.
    rem Also note the quoting as JRE_HOME may contain spaces.
    set _RUNJAVA="%JRE_HOME%injava.exe"
    :gotRunJava
    
    rem Don't override _RUNJDB if the user has set it previously
    rem Also note the quoting as JAVA_HOME may contain spaces.
    rem 如果_RUNJDB环境变量不为空就结束,实际不设置,所以将其设置为JAVA_HOMEinjdb.exe
    if not "%_RUNJDB%" == "" goto gotRunJdb
    set _RUNJDB="%JAVA_HOME%injdb.exe"
    :gotRunJdb
    
    goto end
    
    :exit
    exit /b 1
    
    :end
    exit /b 0
    
    rem 整个脚本设置了JAVA_HOME,java.exe和jdb.exe目录
    
    
  • 相关阅读:
    Android 黑科技保活实现原理揭秘
    Flutter +携程=?
    图解设计模式-Prototype模式
    图解设计模式-Singleton模式
    比较B-tree索引与Hash索引
    类元数据Class Metadata
    DriverManager类
    XMLMapperBuilder类
    PooledDataSource类
    Java并发编程的艺术(笔记)
  • 原文地址:https://www.cnblogs.com/kibana/p/9261350.html
Copyright © 2011-2022 走看看