How to Build a Path in Eclipse Java

A build path tells the Java Eclipse compiler where to find the source code files for the project. You export your project as a JAR file in Eclipse, then run the code in the DOS prompt with the "classpath" setting. This technique allows you to run the program from a command prompt to test the code. The JAR file is a compiled resource, so your users can use the file to run Java programs on their desktops.

Instructions

    • 1

      Click the Windows "Start" button and type "eclipse" in the text box. Press "Enter." In the search window, double-click "Eclipse.exe" to start the program. Open your Java program to load it in the compiler.

    • 2

      Click the "File" menu item. Click "Export." A configuration window opens for the JAR file. Check each file you want to compile and ensure the ".classpath" file is also checked. Choose a location to store the JAR file and click "Finish." Eclipse creates the classpath file and compiles the JAR.

    • 3

      Click the Windows "Start" button and type "cmd" in the search text box. Press "Enter" to open the DOS command prompt.

    • 4

      Type the following command to run the Java program:

      java -classpath program.jar com.program

      Replace "program.jar" with the name of your own JAR file and replace "com.program" with your own Java path name.

    • 5

      Press "Enter" to run the JAR file. The classpath is found in the exported file stored by Eclipse, and the program runs on your desktop.

Related Searches:

References

Comments

Related Ads

Featured