Every time I feel set Java environment variable good trouble ah. Setting environment variables with batches is a good choice, but it is not a global environment variable that is set up in DOS. Later found WMIC can set the global environment variables, so directly to do batch processing slightly
Copy horizontal down to Notepad, save as a. bat suffix file, double-click to set the environment variable automatically. Only need to enter JAVASDK and Tomcat installation path ~
To set the Java environment variables:
--------------------------------------------------------Start----------------------------------------------------
@echo off Echo before you configure the environment variables for you, enter the installation path for your Java SDK. set/p javasdk_dir= Please enter the installation path for the Java SDK (such as C:\Java\j2sdk1.5.0):::* ***************************************************** :: Environment-system Environment settings management (global) *:: Get TEMP environment variable *:: WM IC environment where "name= ' temp" Get username,variablevalue *:: Change PATH environment variable value, add E:\too LS *:: WMIC environment where "name= ' path" and Usernam E= ' <system> ' "Set variablevalue="%path%;e:\tools "*:: New system environment variable home, value is%homedrive%%homepath% *:: WMIC environment Create Name= "Home", Username= "<system>", variablevalue= "%homedrive %%homepath% "*:: Delete Home environment variable *:: WMIC environment where "name= '" "Delete *::* * Echo Setting JAVA environment variables ... echo new java_home:%javasdk_dir% WMIC environment create Name= "Java_home", username= "<system>", Variablevalue= "%javasdk_dir%" echo increases path:;%%java_home%%\bin;%%java_home%%\jre\bin WMIC environment where "name=" Path ' and username= ' <system> ' ' Set variablevalue= '%path%;%%java_home%%\bin;%%java_home%%\jre\bin ' echo New classpath:.;
%%java_home%%\lib;%%java_home%%\lib\dt.jar;%%java_home%%\lib\tools.jar; WMIC environment Create Name= "CLASSPATH", username= "<system>", variablevalue= ".;
%%java_home%%\lib;%%java_home%%\lib\dt.jar;%%java_home%%\lib\tools.jar; " Pause
--------------------------------------------------------End----------------------------------------------------
To set the TOMCAT environment variable:
--------------------------------------------------------Start----------------------------------------------------
@echo off echo Please enter your tomcat installation path before you configure the environment variables for you. set/p tomcat_dir= Please enter the installation path for Tomcat (such as C:\apache-tomcat-7.0.42):::* ************************************************** :: Environment-system Environment settings management (global) *:: Get TEMP environment variable *: : WMIC environment where "name= ' temp" Get username,variablevalue *:: Change PATH environment variable value, add e:\ Tools *:: WMIC environment where "name= ' path" and user Name= ' <system> ' "Set variablevalue="%path%;e:\tools "*:: New system environment variable home, value is%homedrive%%homepath% *:: WMIC environment Create Name= "Home", Username= "<system>", variablevalue= "%homedr ive%%homepath% "*:: Delete Home environment variable *:: WMIC environment where "name= '" "Delete *::* * Echo Setting TOMCAT environment variable ... echo new tomcat_home:%tomcat_dir% WMIC environment create Name= "Tomcat_home" username= "<system" > ", variablevalue="%tomcat_dir% "echo new catalina_home:%tomcat_dir% WMIC environment create Name=" Catalina_home ", Username= "<system>", variablevalue= "%tomcat_dir%" echo new catalina_base:%tomcat_dir% WMIC Environment create Name= "Catalina_base", username= "<system>", variablevalue= "%tomcat_dir%" Echo increased path:;%tomcat_dir%\lib;% Tomcat_dir%\bin WMIC environment where "name= ' path ' and username= ' <system> '" Set variablevalue= "%path%;%% Catalina_home%%\lib;%%catalina_home%%\bin "Pause
--------------------------------------------------------End----------------------------------------------------
Enter the installation path for JAVASDK and Tomcat:
Note: The path should not be entered incorrectly, and the JAVASDK installation path is not the Java installation path. Just find the installation path and copy and paste it over.
JAVASDK:
Tomcat:
Check that the Java environment variable is set correctly.
Tomcat's environment variable is set correctly.
Tomcat started successfully.