Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
student:eclipse:help [2023/04/27 14:13] bernstdhstudent:eclipse:help [2024/03/25 17:24] (current) bernstdh
Line 111: Line 111:
 === Creating Packages === === Creating Packages ===
  
-Some courses require that code within a package be organized in packages and some do not. To create a package:+Some courses require that code within a project be organized in packages and some do not. To create a package:
  
   - Right-click on the appropriate project (in the package explorer).   - Right-click on the appropriate project (in the package explorer).
Line 119: Line 119:
   - Unless you are explicitly told to do so, **do not** check the "Create package-info.java" box.   - Unless you are explicitly told to do so, **do not** check the "Create package-info.java" box.
  
 +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/folder inside of the %%data%% directory/folder). This is to remind you that the statement %%import data.*%% does not import the subpackage %%data.io%%.
  
 === Creating Files === === Creating Files ===
Line 132: Line 133:
   - Pull down to <key>New</key>.   - Pull down to <key>New</key>.
   - Pull over to <key>Class</key>.   - Pull over to <key>Class</key>.
-  - Enter the name of the package in the "Package" field (or leave it blank if the class is in the default package).+  - Enter the full name of the package (including any subpackages, delimited with a .) in the "Package" field (or leave it blank if the class is in the default package).
   - Enter the name of the class in the "Name" field.   - Enter the name of the class in the "Name" field.
   - Optionally, complete the other fields and make the appropriate selections.   - Optionally, complete the other fields and make the appropriate selections.
Line 168: Line 169:
 To instruct Eclipse to use them when compiling and executing you should: To instruct Eclipse to use them when compiling and executing you should:
  
-  - Create a directory/folder for the ''%%.class%%'' files or ''%%.jar%%'' file external to the workbench/eclipse-workspace (e.g., ''%%existingcomponents%%'').+  - Create a directory/folder for the ''%%.class%%'' files or ''%%.jar%%'' file external to the workbench/eclipse-workspace (e.g., ''%%downloads%%'').
   - Copy or download the ''%%.class%%'' files or ''%%.jar%%''  file to that directory/folder.   - Copy or download the ''%%.class%%'' files or ''%%.jar%%''  file to that directory/folder.
   - Open Eclipse.   - Open Eclipse.
Line 236: Line 237:
  
 To find a matching curly bracket (either opening or closing) type <key>Ctrl</key>+<key>Shift</key>+<key>P</key>. To find a matching curly bracket (either opening or closing) type <key>Ctrl</key>+<key>Shift</key>+<key>P</key>.
 +
 +
 +==== Counting Lines of Code (LOC) ====
 +
 +Though there are several software metrics plug-ins available, there is an easy "hack" for counting lines of code.
 +
 +  - Click on <key>Search</key>+<key>File</key>
 +  - Enter ''\n'' (to count all lines) or ''\n[\s]*'' (to count non-blank lines) in the "Containing text:" field
 +  - Check the "Regular expressions" checkbox
 +  - Enter ''*.java'' (or other file type) in the "File name patterns" field
 +  - Select the appropriate scope
 +  - Click on <key>Search</key>
 +
 +The top line of the "Search" panel will show the total number of matches (i.e., lines). You can also get matches/counts by package, file, etc.
 +
  
  
Line 280: Line 296:
  
  
-In Eclipse, applications are started using the <key>Run</key> button or the "Run" menu.+In Eclipse, applications are started using the <key>Run</key> button or the "Run" menu. They are configured from the 'Run" menu using the "Run Configurations..." option. 
 + 
 + 
 +=== Run Configurations === 
 + 
 +There are different kinds of run configurations, the two most important are configurations for Java Applications and configurations for JUnit tests.
  
 +To create a run configuration, select the appropriate type and click on the [New launch configuration] button (that looks like a blank sheet with a + in the upper-right corner). Then, fill in the name and other relevant information. For Java Applications, the most important information is entered on the "Main" tab. For JUnit tests, the most important information is entered on the "Test" tab.