Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Tools of the trade, Part 1

Discover the world of Java tools by exploring JCreator

  • Print
  • Feedback

Page 6 of 6

Caution
Attempting to use jdb's locals command to view the contents of a classfile's local variables can fail if javac compiled the equivalent source file with the -g debugging option unspecified.


For a sense of what JCreator/jdb debugging looks like, examine Figure 4, which shows the results of trying to execute String s = "abc"; System.out.println (s.charAt(s.length()));.

Figure 4. A debugging session with JCreator and the SDK's jdb debugger. Click on thumbnail to view full-size image.

Tip
JCreator requires you to explicitly tell the debugger to stop. Stop jdb by typing exit on the Debug tab.


Customize JCreator

JCreator provides extensive customization features to personalize your experience. These features range from resizing windows to moving/docking toolbars to a Configure menu with Options and Customize menu items. Four of the many entities you can customize are project templates, code templates, line number display, and syntax highlighting colors:

Project templates

Think of a project template as providing canned code common to many projects. When you create a project from a template, JCreator places the template's source code in the project's main Java file. Furthermore, depending on the template, JCreator automatically generates an HTML file for that project.

JCreator comes with three project templates associated with the Basic Java Application (an application with a simple GUI), Basic Java Applet (an applet with a simple paint(Graphics g) method), and Empty Project (no prewritten source code) categories. Though suitable for a variety of Java projects, those templates are not exhaustive, and you will probably want to create your own project templates. For example, you might want to create a simple Java application whose code fits into a framework resembling the following code fragment:

class SomeApp
{
   public static void main (String [] args)
   {
   }
}


Except for SomeApp (which should be a generic symbol that represents the project name), let's place this source code into a new project template called Simple Java Application. Complete the following steps to accomplish that task:

About the author

Jeff Friesen has been involved with computers for the past 20 years. He holds a degree in computer science and has worked with many computer languages. Jeff has also taught introductory Java programming at the college level. In addition to writing for JavaWorld, he has written his own Java book for beginners? Java 2 by Example, Second Edition (Que Publishing, 2001; ISBN: 0789725932)?and helped write Using Java 2 Platform, Special Edition (Que Publishing, 2001; ISBN: 0789724685). Jeff goes by the nickname Java Jeff (or JavaJeff). To see what he's working on, check out his Website at http://www.javajeff.com.

Read more about Tools & Methods in JavaWorld's Tools & Methods section.

  1. Create a directory in the ...\JCreator\Templates\ directory named Template_N, where N is the next highest template number. Because JCreator starts with three project templates, create the Template_4 directory in the Templates directory. After completing that task, I end up with a C:\Program Files\Xinox Software\JCreator Pro\Templates\Template_4 directory on my platform.
  2. Copy files setup.tst and Project_Name.java from the ...\JCreator\Templates\Template_1 directory to the Template_4 directory.
  3. Edit setup.tst so that the new project category name appears beside the [LABEL] tag. Once you are done, your setup.tst should look like the following:

    ; This file contains the setup information for a template project.
    [LABEL]         Simple Java Application
    [DESTPATH]  "classes"
    
  4. Edit Project_Name.java so that it contains the following:

    /*
     * @(#)<PROJECT_NAME>.java 1.0 
    
  • Print
  • Feedback

Resources