Running Java programs remotely

You can run an IBM® i Java™ program remotely in the i Java Transform and Run view or in the Launch Configurations window.

Before you begin

Any Java program that you run must be an application (a class that contains a main method).

Before you can run an IBM i Java program, you must export Java class files to an IBM i integrated file system directory. Java source files are required on an IBM i server to debug IBM i Java programs.

About this task

In the i Java Transform and Run view

Procedure

  1. Open a Java perspective if one is not currently available: Click Window > Open Perspective > Java.
  2. Switch to the Transform and Run view:
    1. Click the down arrow next to the Run icon on the workbench menu bar.
    2. Select Run As > Remote Java Application in IBM i view.
  3. To populate the Working Folder field, click Browse to select a directory in the Browse For Folder window.
  4. Optional: Click Advanced Options to specify program parameters, properties, and IBM i run options. In the Select i Options window, choose the properties you want and click OK. The options are described in the related references below.
  5. Click the Run remotely tab.
  6. In the Class field, enter the name of the class file.
  7. Click Run to start the remote invocation. The Console out field displays output or any errors.
  8. Use the Console in field to enter information for the program (if the program asks for input). Data entered in this field is passed to the remote program when you press Enter.

Results

The Java application runs on the IBM i server. At any time while the program is running, you can click Stop. Click Clear Console to clear the Console out field.

In the Launch Configurations window

  1. Open a Java perspective if one is not currently available: Click Window > Open Perspective > Java.
  2. Click the down arrow next to the Run icon on the workbench menu bar.
  3. Select Run. The Create, manage, and run configurations window opens.
  4. Click Java Application in i Server. Click New to create a configuration of the selected type.
  5. Optional: Give the configuration a name.
  6. Under the Main tab, fill in the name of the project and the name of the Main class in your project. Browse to the Remote i working folder, enter the name, or select the name from the drop-down list. This is the IFS folder containing the remote package, or the class itself if the class does not have a package.
  7. Optional: Use the other tabs to add parameters, set class path, and so on.
  8. Click Run to run the program.

After you define a configuration, it appears as a shortcut in the down-arrow menu.

What to do next

If the Java class file is on the IFS, you can run it in the Remote Shell view. In the Remote System Explorer, right-click the IFS Files subsystem under the connection and select Launch Shell. See the related task on working with command shells.

Feedback