Creating a Console Application

See Also

A console application has no graphical user interface. You can use the nongraphical classes in either WFC or the Java API to develop your application.

Note   Before you use the following procedure to create a console application, close any projects that you may already have open. (On the File menu, click Close All.)

To create a console application

  1. On the File menu, click New Project.

  2. On the New tab, expand the Visual J++ Projects folder and click Applications. Then select the Console Application icon.

  3. In the Name box, enter a name for your project.

  4. In the Location box, enter the path where you want to save your project, or click Browse to navigate to the folder.

  5. Click Open. A collapsed view of your project appears in Project Explorer.

  6. In Project Explorer, expand the project node. A file with the default name of Class1.java has been added to your project.

Note   Renaming this file does not rename the associated class in the source code, and vice versa. You must manually change all instances of the old name. (Note that you can create an empty project and then add a class with the ClassMain template. This two-step process allows you to name the class before it is created.)

Adding Code in the Text Editor

To view the source code that was generated, double-click Class1.java in Project Explorer. Program execution begins with the main method.

To add code to the application

For more information about modifying your code in the development environment, see Editing Code.

Building and Running the Application

After you build your application, you can run it from either the development environment or from the command line.

To build and run your application

  1. On the Build menu, click Build. Any compilation errors or messages appear in the Task List. (Double-clicking an error in the Task List moves the insertion point in the Text editor to the error.) Correct the errors and rebuild your applet.

  2. To run the application from the development environment, click Start on the Debug menu.

  3. To run the application from the command line, use JVIEW. At the command prompt, type jview Class1 from the directory location of your project.