Running your programs

In this section, you will learn more about running VJET programs in the workbench.

  1. Please make sure the VJET file MyTest.js is opened in your editor area.
  2. You can copy the following code and insert them into props.

    Note: add the method before the closing brackets of the block.

    //>public void main(String... args) 
    main : function(args){
        new this.vj$.Test(true, 0).setClose();
        vjo.sysout.println("Hello World");
    } 
    
  3. From Script Explorer view, select Test.js file, Right click on it.
    From context menu, select Run As > VJET JS Application.

    Note: the Run As context menu is also available in other places.

    Running your program
  4. The program will print two messages in your Console view if it run successfully. One is "Your account has been CLOSED!" and the other is "Hello World".

    Console view

  5. To specify arguments, use the drop-down Run menu in the toolbar and select Open Run Dialog....

    Or you can also go through Context menu. Run As > Open Run Dialog...

    Run menu of the toolbar

  6. This time, the Launch Configurations dialog opens with the MyTest launch configuration selected. A launch configuration allows you to configure how a program is launched, including its arguments and other options.  (A default launch configuration was created for you when you chose Run > VJET JS Application).

    Run Dialog

  7. Replace the following code of the main method :
    //>public void main(String... args) 
    main : function(){
        var x = arguments;
        var size = x.length;
        vjo.sysout.println("Argument size:" + size);
        vjo.sysout.println("-first:" + x[0]);
        vjo.sysout.println("-second:" + x[1]);
    } 
    
  8. Select the Arguments tab and type Hello World in the Program arguments area.

    Arguments tab of the launch configuration dialog

  9. Click Run. The program will print three messages if it run successfully.

    Console showing program output

  10. Switch to the Debug perspective. In the Debug view, notice that a process for the last program launch was registered when the program was run. By default, the Debug view automatically removes any terminated launches when a new launch is created. You can reach this perspective throuth Window menu > Open perspective > Other.. > Debug

    Debug view showing two terminated run launches

    Note: You can relaunch a terminated process by selecting Relaunch from its context menu.
  11. Select the drop-down menu from the Run button in the workbench toolbar. This list contains the previously launched programs. These programs can be relaunched by selecting them in the history list.

    Run drop down menu from the workbench toolbar

  12. From the context menu in the Debug view (or the equivalent toolbar button), select Remove All Terminated to clear the view of terminated launch processes.

    Debug view showing context menu

Related reference