Use batch processing to set JDK environment variables (available in Win7) and JDK

Source: Internet
Author: User

Use batch processing to set JDK environment variables (available in Win7) and JDK

You are welcome to discuss it. please correct me if any errors exist.

If you need to reprint, please indicate the source of http://www.cnblogs.com/nullzx/ 1. JDK Environment Settings

Generally, you can set JDK environment variables according to most online tutorials. However, in some special cases, such as the computer with the restoration system installed in the lab, the computer in the classroom for the teacher in class, and so on, we may need to repeat the operation. In general, I put JDK in a USB flash drive. The drive letter may change after each class is started, so it is very cumbersome to set the environment variable every time. For repetitive work, it must be handed over to the computer. After checking the relevant information on the Internet, add some modifications (the last step of the source code is more complex, and some problems are used in Win7) to create the following batch processing files, you do not need to enter any path to use this file.

@ Echo offset regpath = HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ Environmentset javahome = % ~ Dp0 % rem LPYecho. echo *************************************** * ******************* echo ** echo * JDK system environment variable settings ** echo **** **************************************** * **************** echo. echo === prepare to set the environment variable: JAVA_HOME = % javahome % echo === Note: If JAVA_HOME exists, it will be overwritten. This operation is irreversible. Please check carefully and confirm it !! === Echo. echo === prepare to set the environment variable (there is .): CLASS_PATH = .; % JAVA_HOME % \ lib \ tools. jar; % JAVA_HOME % \ lib \ dt. jar ;. echo === Note: If CLASS_PATH exists, it will be overwritten. This operation is irreversible. Please check carefully and confirm it !! === Echo. echo === prepare to set the environment variable: PATH = % JAVA_HOME % \ binecho === note: the PATH will be appended to the end, echo. set/p en = confirm and press enter to start setting! Echo. echo. echo. echo. echo = new environment variable JAVA_HOME = % javahome % setx "JAVA_HOME"/M % javahome % echo. echo. echo = new environment variable CLASS_PATH = % JAVA_HOME % \ lib \ tools. jar; % JAVA_HOME % \ lib \ dt. jar ;. setx "CLASS_PATH"/M ".; % JAVA_HOME % \ lib \ tools. jar; % JAVA_HOME % \ lib \ dt. jar; "echo. echo. echo = new append environment variable (append to end) PATH =; % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin; set append =; % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin; set newPat H = % Path % append % setx "Path"/M % newPath % echo. echo. echo === press any key to exit! Pause> nul
2. Usage

1. Create a TXT file, copy the above batch processing code to the new TXT file sink, and then change the suffix to bat

2. Place the bat file in the JDK installation directory (as shown in)

3. Double-click to run

Note:

(1) run the file only once. Running the file multiple times may cause this problem. The system environment variable Path constantly adds the JDK directory.

(2) If you want to delete the environment variable, delete it in the system. 3. Refer to the article.

Http://blog.csdn.net/lpy3654321/article/details/9822439

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.