Friday 27 February 2015

Set The Classpath In Eclipse

A classpath is a parameter that indicates to the Java Virtual Machine where user-defined classes and packages are located. Are you working on a project in Eclipse and need to set the classpath? You can set the classpath in a few steps.


With Eclipse, you don't actually type out a classpath as you would in a normal Java application. Instead you just add libraries, folders and projects in the Properties window of your Project in Project Explorer. Eclipse makes it quite easy to manage your classpath.


Instructions


1. Open Eclipse. Look for the Project Explorer. You should have a project there. (If not, you won't have a need to set the classpath.)


2. Right-click on the project name and select "Properties." Alternately, you can click on the project name and press the "Alt" and "Enter" keys simultaneously. A window will appear.


3. Select "Java Build Path." Several tabs will appear, including "Source," "Projects" and "Libraries."


4. If you want to add source code from the current project, select the "Source" tab and then click the "Add Folder" button.


5. If you want to add the code from another project in Eclipse to the classpath of this project, then select the "Projects" tab. Then click on the "Add" button. You'll be able to select and add projects from there.


6. Finally, if you want to add jar files, select the "Libraries" tab. From there, you can add either internal or external jars. An internal jar is a jar that is located in the directories of your project. To add an internal jar, click the "Add Jar" button and then navigate to the jar and add it. Click "Add External Jar" if you want to add a jar that is located on your computer hard drive but not in this project.


7. If you want to add classes instead of a jar file, then just click on the "Add Class Folder" under the "Libraries" tab.

Tags: click button, code from, need classpath, project Eclipse, Project Explorer, project name