0

I want to know what is the difference between adding a class path/library by "1) Eclipse>>Preferences>>Java>>Build Path >> Add Class path Variable/Library", and adding a classpath/library by adding it to an specific project by "2) Left-Click on the Project >> Properties>> Java Build Path >> Add Library OR Add class path"?

If these methods are different. How should I use each of them?

vahid
  • 315
  • 5
  • 13

2 Answers2

0

i. By the first ("1 Eclipse>>Preferences>>Java>>Build Path >> Add Class path Variable/Library" ) method you will have two different option .. One is to add a classPath variable and one is to add the user libraries. The CLASSPATH environment variable tells the Java Virtual Machine and other Java applications where to find the class libraries, including user-defined class libraries. On the other hand adding a a user libraries means that you r just adding some user defined libraries nothing more than that.

ii. On the Second way (Left-Click on the Project >> Properties>> Java Build Path >> Add Library OR Add class path") you have the various options to add various type of libraries including the user libraries.Other than user libraries you can add junit libraries and many more.

kaushik
  • 312
  • 1
  • 7
  • So, what is the difference in adding a class path/library using method (1) and method (2)? Is this about the "junit libraries and many more." we can ONLY have with method (2)? – vahid Dec 06 '15 at 06:22
  • In method(1) you can add the classpath variable. as well as user libraries. but in method (2) you cant add the classpath variable but you can add the user libraries, Junit libraries, JRE system library etc... – kaushik Dec 06 '15 at 07:12
0

The 'Preferences' Class path / Libraries entries just define the names and contents of variables and libraries. This does not add these entries to the build path of any project.

Once you have defined variables and libraries in the Preferences you can then add them to individual projects using the Project Properties Build Path.

Using a separate definition in the Preferences allows you to change the actual value of the variable / library without having the change every project.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • This addresses my question. So, 'Preferences' Class path / Libraries is basically a repository where one can store all the variables/libs and add them to the desired Projects via Project Properties Build Path. – vahid Dec 06 '15 at 18:44