How to Use JCreator LE (English)

How to Use JCreator LE

Downloading and Installing

JCreator TM is a trademark of Xinox Software. JCreator LE is a simple Java IDE for Windows. You can download this freeware version of JCreator from jcreator.comJCreator runs on Windows machines and requires Sun’s Java JDK (a.k.a. SDK) installed.  Install the JDK and documentation first, then JCreator.

Configuring Default Properties

Make sure there is no workspace open (choose File/Close Workspace if one is open). From the Configure menu, choose Options... In the dialog box that pops up expand the Editor node and click on Java.

Set the tab size to 2 and select the Insert spaces option.  You may find it more convenient at the beginning to uncheck the Show line numbers and Autoindent options:

Click on the Directories node and enter C:\mywork (or a folder name of your choice) in the Default Project Directory line:

Click on the Code Insertion node and check the Start open brace on new line box.

Then click OK.

Setting up Workspaces and Projects

JCreator organizes your programs into workspaces and projects.  A workspace contains one or several projects.  A project contains one or several programs.  For example, you can have a workspace for all the labs and exercises in one chapter of a textbook, and a project for a particular lab or set of exercises.  You give names to your workspaces and projects.

Workspaces and projects are akin to folders and subfolders.  In fact, it is customary to keep all the files for a given project in the same folder.  The name of the project folder is usually the same as the name of the project.  When you create a project, JCreator creates a folder for it, unless you choose an existing folder.

JCreator keeps the descriprion of a workspace in a file with the extension .jcw.  The projects within the workspace can be scattered on disk, but it is customary to group them as subfolders in the same folder.  The .jcw file can be placed in that folder, too.  For example:

Here the folder Ch02 contains the workspace file Ch02.jcw and three project folders for this workspace: Exercises, Hello, and HelloGui.

To create an empty workspace, first create a folder for your workspace using Windows Explorer (for example, C:/mywork/JavaMethods/Ch03).  Then open or return to JCreator, click on File/New, and choose Blank Workspace...:

In the dialog box that pops up, navigate to the desired location for the workspace files (for example, C:\mywork\JavaMethods\Ch03 and enter the name for your workspace (for example, Ch03):

Click Finish.

You can open an existing workspace by going to File/Open Workspace....

JCreator keeps track of recently opened workspaces and allows you to quickly open one of them and load all its projects.  To do this, choose File/Recent Workspaces.

To add a new project to the currently open workspace, go to Project/New Project... or File/New and choose Project....  Click on Empty Project, then Next:

In the dialog box that pops up, enter the project name (for example, FirstSteps):

JCreator automatically adds the project name to the location lines.  Click Finish.

To delete a file from the project, click on that file in the file list and press Delete.

Entering and Running a Simple Program

Set up a workspace with a project in it, as described above.  If the workspace has several projects, right-click on the project you want to work on and choose Set as Active Project.

You can add an existing Java source file to your project or create a new Java class (source file) from scratch.  To add an existing file, go to Project/Add files..., navigate to the folder that holds the file, double-click on the file (or single click and click Open), then click on the Add button.  The file will be copied into your project folder and added to the project description.  You can add several files at once from the same folder by clicking on them while holding the Ctrl key down.  If you need to add an .html or a data file, choose All Files in the File Type pulldown list.

Adding files is a common operation, so you might want to put the Add files button to the toolbar (Configure/Customize...).

To create a new Java file, go to Project/New class... or click on the New class button on the toolbar.  In the dialog box that pops up, enter the class name and check the desired options (such as “public,” “Generate main,” etc.) and click Finish.  For example:

Edit the text of your class.  For example:

To edit a file, double-click on its name in the file list on the left.  Several files from the same or different projects may be open at the same time.  You can choose one of them for editing by clicking on the corresponding tab below the edit window.

To compile all the classes in the project, go to Build/Compile Project or press F7.

To run the program, go to Build/Execute Project or press F5 or click on the Execute button (a triangle pointing to the right).

Note: you must successfully compile the classes before you can run the program.

To redirect program’s output from Command Prompt to JCreator‘s general output window:

JCreator provides context-sensitive Java API help.  To access API for a library class, position the cursor on the class’s name in the source code and press Ctrl-F1.

Choosing Which Program to Run

JCreator runs the program from the active project.  If the workspace has several projects, right-click on the project you want to work on and choose Set as Active Project.

Your project can hold several executable programs.  You can choose which one to run in several ways:

  1. Open the class you want to run in the editor (or make it active by clicking on its tab), then go to Build/Execute File or click on the Execute File button (right-pointing triangle with the document icon on the background).

  2. Click on the pulldown arrow next to the Build/Execute Project button and choose Configuration....  Click Default, click Edit, and pick the default class to run from the pulldown list.  For example:

    Click OK twice.  The chosen class becomes the default executable for F5, etc.

  3. Create a new confiduration.  Click on the pulldown arrow next to the Build/Execute Project button and choose Configuration....  Click New, enter a nickname for your program and pick the class to run from the pulldown list.  For example:

    Click OK twice.  The nickname will be added to the list of executables under the Execute button.

Setting Up Command-Line Arguments

JCreator allows you to change the default run-time configuration for your program; in particular, it lets you set the command-line arguments.  Click on the pulldown arrow next to the Build/Execute Project button and choose Configuration....  Click Default, click Edit.

Another dialog box pops up.  Enter the desired command-line arguments in the “Main(…)” field.  For example:

Click OK twice.

You can create and name a number of configurations with different run-time arguments.  You can copy configurations and edit them.

JCreator also allows you to define a number of “global” configurations.  To do that, go to Configure/Options menu and choose JDK Tools. The dialog box that pops up lets you copy the default configuration under a different name and edit it.  In particular, you can create a configuration that prompts you for command-line arguments each time you run a program.  See JCreator‘s help (under “Contents/How to” look for “How to set the Main function arguments”).  You can choose a “global” configuration you want to use for a particular project from the Project/Project Settings... menu.

Running Applets

If your project contains an HTML file with an <applet> tag, JCreator assumes that your project is an applet and automatically dispatches Applet Viewer for that HTML file when you execute the project.  If your project has several executables, you can pick the HTML file as the default or one of the executable configurations.

Adding jar Files to Projects

In Java, it is common to combine several classes in one .jar (“java archive”) file.  Library classes are stored that way.  Larger projects (such as the Case Study in the AP program) use jar files.  You can create your own jar files combining several classes, too.

In JCreator you can simply add a jar file to the project.  The procedure is the same as adding a Java file, except when you navigate to the folder where the jar file resides, choose All files from the pulldown list.

The above method, however, copies the jar file into the project folder.  This is wasteful if the same jar file is used with many projects.  There is a more economical way.  JCreator allows you to define a set of jar files under a single name of your choice.  Once a set is defined, you can add the whole set to any project.

Open a workspace with a project.  To define a set of jar files, go to Project/Project Settings... and click on the Required Libraries tab:

Click New... and in the dialog box that pops up enter a name of your choice for the set of jars, click on the Classes tab, and click on the “Add >” button.  The submenu that pops-up gives you a choice of adding a “path” (a folder that contains .class files) or an “archive” (one or several jar files).  Choose Add Archive..., navigate to the desired jar file(s), then click OK.  The selected jar file(s) is (are) added to the list.  For example:

Repeat as necessary, then click OK.

Click on the checkbox next to the jar set to add these jars to the current project.  For example:

Click OK.

Once a set of jars has been defined, JCreator remembers it and makes it available to any project in any workspace.  Check the checkbox next to a set’s name to add that set to the project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s