Creating a Console Application
A console application has no graphical user interface. You can use the nongraphical classes in either http://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
On the File menu, click New Project.
On the New tab, expand the Visual J++ Projects folder and click Applications. Then select the Console Application icon.
In the Name box, enter a name for your project.
In the Location box, enter the path where you want to save your project, or click Browse to navigate to the folder.
Click Open. A collapsed view of your project appears in http://msdn.microsoft.com/en-us/library/aa243138(v=vs.60).aspx .
- 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
To add code to the application
In the Text Editor, add the following code after the
//TODOcomment inside the
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: " + str.substring(10,20)); System.out.println("The uppercase string is: " + str.toUpperCase());
For more information about modifying your code in the development environment, see http://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
On the Build menu, click Build. Any compilation errors or messages appear in the http://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.
To run the application from the development environment, click Start on the Debug menu.
To run the application from the command line, use http://msdn.microsoft.com/en-us/library/aa266196(v=vs.60).aspx . At the command prompt, type
jview Class1from the directory location of your project.