Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
student:eclipse:help [2021/08/03 14:38] – bernstdh | student:eclipse:help [2024/03/25 17:21] – bernstdh | ||
---|---|---|---|
Line 55: | Line 55: | ||
Unless you are specifically told to do so, **do not** create a %%module-info.java%% file (i.e. **do not** create a module). | Unless you are specifically told to do so, **do not** create a %%module-info.java%% file (i.e. **do not** create a module). | ||
+ | |||
+ | Also, unless you are specifically told otherwise, select the option to create separate %%src%% and %%bin%% directories/ | ||
+ | |||
If you are using Checkstyle, you must activate it for the newly created project. To do so: | If you are using Checkstyle, you must activate it for the newly created project. To do so: | ||
Line 64: | Line 67: | ||
Eclipse projects can be exported as '' | Eclipse projects can be exported as '' | ||
+ | |||
+ | |||
+ | === Converting a Generic Project to a Java Project === | ||
+ | |||
+ | Eclipse has many different kinds of projects. Java projects have a " | ||
+ | |||
+ | - Right-clicking on the project icon in the package explorer. | ||
+ | - Pulling down to " | ||
+ | - Selecting " | ||
+ | - Clicking on < | ||
+ | - Select " | ||
+ | |||
=== Customizing the Formatter === | === Customizing the Formatter === | ||
Line 96: | Line 111: | ||
=== Creating Packages === | === Creating Packages === | ||
- | Some courses require that code within a package | + | Some courses require that code within a project |
- Right-click on the appropriate project (in the package explorer). | - Right-click on the appropriate project (in the package explorer). | ||
Line 104: | Line 119: | ||
- Unless you are explicitly told to do so, **do not** check the " | - Unless you are explicitly told to do so, **do not** check the " | ||
+ | Subpackages can be created by including a dot/period in the name. So, for example, if you have a %%data%% package you can create a subpackage named %%data.io%% simply by including the dot/period in the name when you create it. However, note that Eclipse will not visually put the %%io%% package insides of the %%data%% package (though it will put the corresponding %%io%% directory/ | ||
=== Creating Files === | === Creating Files === | ||
Line 117: | Line 133: | ||
- Pull down to < | - Pull down to < | ||
- Pull over to < | - Pull over to < | ||
- | - Enter the name of the package in the " | + | - Enter the full name of the package |
- Enter the name of the class in the " | - Enter the name of the class in the " | ||
- Optionally, complete the other fields and make the appropriate selections. | - Optionally, complete the other fields and make the appropriate selections. | ||
Line 144: | Line 160: | ||
=== Adding Existing Source Files to a Project === | === Adding Existing Source Files to a Project === | ||
- | The easiest way to add existing source (e.g., '' | + | The easiest way to add existing source (e.g., '' |
=== Using Third-Party .class/.jar Files === | === Using Third-Party .class/.jar Files === | ||
+ | You will sometimes be given the byte code (i.e., the '' | ||
- | You will sometimes be given the byte code (i.e., the '' | + | To instruct Eclipse to use them when compiling and executing |
- | + | ||
- | - Create a directory/ | + | - Create a directory/ |
- | - Copy the '' | + | - Copy or download |
- Open Eclipse. | - Open Eclipse. | ||
- Select a project. | - Select a project. | ||
- | - Click on < | + | - Click on < |
- | - Click on < | + | - Click on < |
- Select the < | - Select the < | ||
- Select the " | - Select the " | ||
- | - Click on one of the following. | + | - As appropriate, |
- | * < | + | |
* < | * < | ||
- | * < | ||
* < | * < | ||
- | - Navigate to the appropriate location and select | + | - Navigate to the appropriate location |
- | - Complete the rest of the process. | + | - Click on < |
- You may need to close and re-open the project for the files to be found. | - You may need to close and re-open the project for the files to be found. | ||
Remember, if you only have the byte code, you will not be able to edit these "third party" classes, but you will be able to use them in your source code. | Remember, if you only have the byte code, you will not be able to edit these "third party" classes, but you will be able to use them in your source code. | ||
+ | |||
+ | == Troubleshooting == | ||
+ | If in trying to run your project you get a '' | ||
Line 220: | Line 237: | ||
To find a matching curly bracket (either opening or closing) type < | To find a matching curly bracket (either opening or closing) type < | ||
+ | |||
+ | |||
+ | ==== Counting Lines of Code (LOC) ==== | ||
+ | |||
+ | Though there are several software metrics plug-ins available, there is an easy " | ||
+ | |||
+ | - Click on < | ||
+ | - Enter '' | ||
+ | - Check the " | ||
+ | - Enter '' | ||
+ | - Select the appropriate scope | ||
+ | - Click on < | ||
+ | |||
+ | The top line of the " | ||
+ | |||
Line 264: | Line 296: | ||
- | In Eclipse, applications are started using the < | + | In Eclipse, applications are started using the < |
+ | |||
+ | === Run Configurations === | ||
+ | |||
+ | There are different kinds of run configurations, | ||
+ | |||
+ | To create a run configuration, | ||
Line 312: | Line 350: | ||
- | You can see all of the breakpoints that are currently set using the Breakpoints view (< | + | You can see all of the breakpoints that are currently set using the Breakpoints view (< |
Line 327: | Line 365: | ||
=== Managing the Variables View === | === Managing the Variables View === | ||
+ | You can control what is shown in the Variables View by clicking on < | ||
+ | |||
+ | === Debugging with Third-Party Classes === | ||
+ | |||
+ | Sometimes you will only have %%.class%% files (or a %%.jar%% file) for some of the classes that you are using. When this happens, you won't be able to step into those classes (because you don't have the source code). However, you can still use the debugger. For example, you can step over any calls to methods that you don't have the source code for. | ||
+ | |||
+ | Frequently in these kinds of situations, what you want to do is run to a breakpoint and the resume execution until that breakpoint (or another one) is encountered. This can be accomplished using the {{eclipse_resume.png}} button in the Debug Perspective. In other words: | ||
- | You can control what is shown in the Variables View by clicking | + | - Set a breakpoint (or multiple breakpoints). |
+ | - Step through your code as far as you can (i.e., until you encounter method calls that you don't have the source code for) or as far as is necessary. | ||
+ | - Click on the resume button. This will resume | ||