Java installation and setting environment variables

Source: Internet
Author: User

Directory:

    1. Java installation (cannot find or Load main class Com.sun.tools.javac.Main)
    2. Setting environment variables

1. Java Installation

Scenario: Do not use the default installation

Problem: Cmd-javac cannot find or load the main class Com.sun.tools.javac.Main

Workaround: Uninstall, reinstall, JDK and JRE cannot be installed in a folder.

e.g. JDK--D:\program\Java\jdk1.7.0_79

JRE--D:\program\Java\jre7

Cause: During the installation of the JDK, a JRE installation will also pop up, and the JDK cannot be installed in the same directory, otherwise it will conflict, causing Javac.exe to be deleted. (Click here to view the original) if you use Java's default installation, a closer look will find that the default installation path for the JDK and the JRE that pops up later is really different.

2. Setting Environment variables

    • Java_home--D:\program\Java\jdk1.7.0_79 (JDK installation path)
    • Path--%java_home%\bin;%java_home%\jre\bin;
    • CLASSPATH--.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;

    • Test environment variable is configured successfully

cmd > Java-version

> javac-version

    • The meaning of a variable

    -->path:

Java variables: Provides parameters for systems and applications.

Environment variable Path: tells the system and application where to store some of the prerequisite programs.

Using the ipconfig command in CMD, essentially Ipconfig is an executable program (similar to >java xxx, >javac xxx), and how does the system know the location of the program? environment variable PATH. If it is not found, it returns "' ipconfig ' is not an internal or external command, nor is it a running program or batch file. ”

    -->classpath: Although the system now finds Java and javac through path, there are still some things that can't be found, what is it? The class library file for Java. such as importing or hiding the imported tear file through import java.xx.xx display. In addition, the location of the program you write is also best put in.

   -->java_home: Well, it's for Jingxiang.

When you set the path, you want to enter:

      C:\Program files\sun\java\jdk1.6.0_02\ Bin

Or prefer to enter:

      %java_home%\ Bin

And if the installation path changes, you only need to modify the Java_home, not the path, Classpath also need to be modified together. -

Here's a more nagging explanation (click here).

Java installation and setting environment variables

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.