Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Creating a Console Application

Visual Studio 6.0

A console application has no graphical user interface. You can use the nongraphical classes in either https://msdn.microsoft.com/en-us/library/aa286468(v=vs.60).aspx or the 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 https://msdn.microsoft.com/en-us/library/aa243138(v=vs.60).aspx .

  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

  • In the Text Editor, add the following code after the //TODO comment inside the main method:
    String str = "The quick brown fox jumped over the lazy yellow dog.";
    System.out.println("The string is: " + str);
    System.out.println("The length of the string is: " + str.length());
    System.out.println("The substring from positions 10 to 20 is: " +
    System.out.println("The uppercase string is: " +

For more information about modifying your code in the development environment, see https://msdn.microsoft.com/en-us/library/aa242915(v=vs.60).aspx .

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 https://msdn.microsoft.com/en-us/library/aa239204(v=vs.60).aspx . (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 https://msdn.microsoft.com/en-us/library/aa266196(v=vs.60).aspx . At the command prompt, type jview Class1 from the directory location of your project.
© 2015 Microsoft