Fixing Java Templates in NetBeans IDE

draindecorumSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

237 views

Fixing Java Templates in NetBeans IDE

NetBeans provides default templates for controlling what the starting program format will look like before you add
any code. Change two of the templates (Java Main Class and Java Class) on your own machine for use in CS1110.
To do this, open NetBeans. Under Tools drop-down menu, select Templates. Expand Java, select Java Main Class,

click Open in Editor. The initial default looks like the following. Delete the yellow highlighted lines.
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
*/
public class ${name} {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
Add the turquoise highlighted lines below. Follow the spacing shown including blank lines. Put 2 spaces after the :
for PROJECT and DESCRIPTION. The long line of * ‘s should have its final / before the red line in the editor.
/* PROJECT:
* AUTHOR: ${user}
* DESCRIPTION:
****************************************************************************/

<#if package?? && package != "">
package ${package};
</#if>
public class ${name} {
public static void main(String[] args) {
// WRITE main's CODE HERE
}
}
Select File (drop-down menu) and Save. Close the above template by clicking the X on the Java Main Class tab in
the editor window. Then make similar changes to Java Class
template (similar to above). Change this template:
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
*/
public class ${name} {
}
into the following (including blank lines, added spaces and indenting as shown):
/* CLASS:
* AUTHOR: ${user}
* DESCRIPTION:
****************************************************************************/

<#if package?? && package != "">
package ${package};
</#if>
public class ${name} {
// WRITE CODE HERE
}
Save it and close the Java Class tab in the editor.