Set Java environment variables for batch processing/set Java environment variables for command lines

Source: Internet
Author: User
1. Batch Processing ProgramJava environment variables can be set automatically

@ Echo off
If exist % 1 \ bin \ java.exe (
If REM enters the correct java2sdk installation directory, it starts to set environment variables.
@ Setx java_home % 1
@ Setx PATH %; % java_home % \ bin
@ Setx classpath % ;.
@ Setx classpath %; % java_home % \ Lib \ tools. Jar
@ Setx classpath %; % java_home % \ Lib \ DT. Jar
@ Setx classpath %; % java_home % \ JRE \ Lib \ RT. Jar
@ Echo on
@ Echo Java 2 SDK environment parameters are set and exit normally.
) Else (
If "% 1" = ""(
If the installation directory is not provided by REM, exit after prompt
@ Echo on
@ ECHO does not provide the installation directory of java2sdk, and does not set anything. Now exit the environment variable settings.
) Else (
If REM provides a non-empty installation directory but does not have bin \ java.exe, the specified directory is the wrong directory.
@ Echo on
@ ECHO: the installation directory of the invalid java2sdk is not set. Now exit the environment variable settings.
)
)

------------------------------------------------------
2 cmd command settings

The command used to temporarily set environment variables in the command line:
Set Path = c: \ j2sdk1.4.0 \ bin

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.