A.4 Using jGRASP


A.4 Using jGRASP

Under Windows, jGRASP is a more flexible and powerful environment to develop programs in Java and in KJP. The tool was designed mainly for Java programs. For KJP, the jGRASP tool needs to be configured so that it will execute the KJP translator when the user issues the Compile command.

A.4.1 Configuring KJP Translator with jGRASP

The following steps will guide you in configuring KJP to work with jGRASP.

  1. Place the KJP translator and additional files in an appropriate directory, such as 'c:\kjp'.

  2. Start jGRASP; the main window appears on the screen as shown in Figure A.4.

    click to expand
    Figure A.4: The jGRASP main window.

  3. On the Settings menu, select Compiler Settings.

  4. Choose Global, click on Language, and select Plain Text.

  5. Click the Environment button, and select Empty.

  6. Click the New button.

  7. A new dialog box appears on the screen with the title: User Compiler Environment (Plain Text). On the top bar of the window, type: KJP. Figure A.5 shows this window.

    click to expand
    Figure A.5: User Compiler Environment.

  8. On the Compile row, type: KJP %FILE.

  9. On the directory column, type: C:\KJP, or any other folder that contains the KJP translator.

  10. Click the Save button.

  11. Click the OK button.

  12. Back on the Global Settings window, click User:kjp. Figure A.6 shows this window.

    click to expand
    Figure A.6: The jGRASP Global Settings window.

  13. Click the Use button.

A.4.2 Translating KJP Programs with jGRASP

To use KJP with jGRASP for translating programs from KJP to Java, follow the sequence of steps:

  1. Start jGRASP.

  2. The jGRASP main window appears on the screen, as shown in Figure A.4. On the left pane, select the folder where the KJP program files are located.

  3. Click the File menu, and select Open. Figure A.7 shows the Open File window.

    click to expand
    Figure A.7: The jGRASP Open File window.

  4. In the Open File, type kpl in the File Extension text-box (far right side), and press the Enter key.

  5. Select the file to open and click the Open button.

  6. The KJP file (with extension kpl) appears on the screen. Edit the file and save, if necessary. Figure A.8 shows the jGRASP edit window.

    click to expand
    Figure A.8: The jGRASP edit window.

  7. Click the Compiler menu and select Compile or click the button with the green cross.

  8. On the bottom pane of the screen, all the messages appear, including any compiler error messages. If there are no errors, the message No syntax errors found appears as the last message.

  9. Edit the file if any errors were found.

  10. Save the file and recompile, if necessary.

  11. To close the file, click the File menu and select Clear.

A.4.3 Compiling Java Programs with jGRASP

After the translation of a KJP program, the corresponding Java program must be compiled with the Java compiler. To compile and execute a Java program, carry out the following sequence of steps:

  1. Click the File menu and select Open.

  2. Select java for the type of file.

  3. Select the desired Java file.

  4. Click the Compiler menu and select Compile, or click the button with the green cross.

  5. The bottom window will display jGRASP: Operation complete.

  6. Click the Run menu, and if desired, select the option Run in MSDOS window.

  7. Click the Run selection, or click the button with the red man running.

  8. If necessary, type the appropriate input data values required by the program when it executes.

A.4.4 Capturing the I/O

This section explains how to capture the console output of an application program running in the jGRASP development environment.

  1. First, load all files and compile the software as you normally would. Any compile errors or "successful" message(s) will appear in the Messages View along the bottom of the screen.

  2. Run the code with the Run in MS-DOS Window selection unchecked. This keeps the output within the jGRASP window's environment and sends the output to the Messages View at the bottom of the screen. You will see the output scrolling while the program is executing.

  3. After the program runs, select the Messages menu bar, and select Save as Text File option. The menu that appears is shown in Figure A.9.

    click to expand
    Figure A.9: The jGRASP Messages menu.

  4. Complete the dialog box, and click save. The resulting text file can be viewed by opening the file in jGRASP (select All files to see it in the dialog box). Of course, it can also be viewed and manipulated in other applications as any text file. Figure A.10 shows the dialog box saving the Run I/O panel.

    click to expand
    Figure A.10: The jGRASP Save Run I/O dialog box.

    This method can be used to generically send any Messages View output, including compiler error logs, to a text file.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net