Eclipse Tutorial VI

Share Eclipse Java Build Path, Eclipse Run Configuration (Run Configuration) and Eclipse Runner today

Eclipse Java build path

Set Java build path

The Java build path is used to find dependent classes when compiling a Java project, including the following:

  • source package
  • Project-related jar packages and class files
  • The class library referenced by the project

We can view and modify the Java build path by using the Java Build Path (Java build path) option in the Java project properties dialog.

The Java Project Properties dialog can be invoked by right-clicking on the specified Java project in the Package Explorer view and selecting the Properties menu item.

Then select Java Build Path in the left window (Java build path).

In the Java build path window we can already refer to the jar package.

The reference jar package can be done in the Libraries tab. In the Libraries tab, we can click Add JARs to add the jar package existing in the Eclipse workspace or click External JARs to import the jar package in other files.

 

Eclipse Run Configuration

Create and use Eclipse run configurations

Multiple run configurations can be created in the Run Configuration dialog. Each configuration can be enabled in the application.

The Run Configuration dialog can be invoked by selecting Run Configurations from the Run menu.

If you want to create a runtime configuration for a Java application, you need to select "Java Application" in the list on the left and click the New button.

The items described in the dialog are:

  • run configuration name
  • Item name
  • main class name

Arguments (parameters) items are:

  • Program arguments (program parameters) can be 0 or more
  • VM arguments (Virtual Machine arguments: virtual machine parameters) can be 0 or more

The Commons tab provides common configurations, such as standard input and output options, which can go to the console or specify files.

Click the Apply button to save the run configuration and click the Run button to re-execute the Java application.

Eclipse to run the program

run java program

We can view in Package Explorer

Java programs can be quickly run in the Package Explorer view.

Package Explorer view:

Right-click the java class containing the main function and select Run As > Java Application

Similarly, you can also select the class containing the main method in the Package Explorer view and press the shortcut key: Alt + Shift + X, J

The following two ways can create a new  Run Configuration (run configuration)  we can use it to start the Java application.

If a run configuration has been created, you can start the Java application by selecting Run Configurations from the Run menu, clicking the name of the run configuration, and then clicking the Run button for the Java application.

The Run option in the Run menu restarts a previously started Java application.

The shortcut key for restarting the previously started Java application is Ctrl + F11.

おすすめ

転載: blog.csdn.net/slave_of_life/article/details/130918281