Eclipse references a class library through CLASSPATH variable

Source: Internet
Author: User

As we all know, Eclipse's project Bulid path can refer to a third-party class library (1),

Figure 1

But there is a drawback to this approach: a reference to a class library is through an absolute path. If there are two computers (office 1, home 1), it is likely to cause eclipse error due to the different path of the class library.

But in fact, the two computers are just the absolute path of the libraries directory, the subdirectory starting from the libraries is fully synchronized.

As long as this condition is met, the class library can be introduced in the following way:

1. Establish CLASSPATH variable. The establishment of a new CLASSPATH variable (2) in window->preferences;

Figure 2

2. Select Add Varibale in the build path, then select the variable entry in the popup window and select Extend ... (3)

Figure 3

3. Select the desired class library in the variable extend window (4)

Figure 4

Thus, the class library is a relative path reference (5) based on the CLASSPATH variable,

Figure 5

As long as you can ensure that all class libraries on both computers are consistent with the relative path starting from a certain directory, you can create Eclipse classpath variable to ensure that the project will not be able to make an error by referencing the class library during the migration of the two computers.

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.