Home > Java > javaTutorial > How Do I Set Java Environment Variables (Including Classpath) in Windows?

How Do I Set Java Environment Variables (Including Classpath) in Windows?

Mary-Kate Olsen
Release: 2024-12-17 19:40:22
Original
318 people have browsed it

How Do I Set Java Environment Variables (Including Classpath) in Windows?

Setting Environment Variables for Java in Windows

When working with Java applications in Windows, it's essential to configure the system's environment variables to ensure the applications can access the necessary resources. This question addresses the specific task of setting the classpath, a fundamental Java environment variable.

Solution

Environment Variables

For Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8 system, set the following user environment variables:

  • JAVA_HOME: C:Program FilesJavajdk1.8.0_112
  • JDK_HOME: %JAVA_HOME%
  • JRE_HOME: %JAVA_HOME%jre
  • CLASSPATH: .;%JAVA_HOME%lib;%JAVA_HOME%jrelib
  • PATH: your-unique-entries;%JAVA_HOME%bin

Optional Recommendations

Additionally, consider the following optional recommendations:

  • Create a user environment variable named JAVA_TOOL_OPTIONS with the value -Dfile.encoding="UTF-8". This ensures Java runs with the UTF-8 character encoding by default.
  • Remove the entry C:ProgramDataOracleJavajavapath; from the system environment variable Path. This ensures consistent environment settings during JDK updates.

The above is the detailed content of How Do I Set Java Environment Variables (Including Classpath) in Windows?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template