Initialize the Project from the CLI

You can now begin working on your Catalyst project from the CLI. The first step is to initialize the project in an empty directory. This will be the home directory of your project and all of the project files will be saved in it.

You can learn more about this from the Project Directory Structure help page. You can learn about initializing a project in detail from the CLI help documentation.

For the news application, we will initialize a job function and the client, and then add an Advanced I/O function to the project directory.

  1. Create a folder for the project on your local machine and navigate to it from the terminal. Initialize a project by executing the following command from that directory:
copy
$
catalyst init
  1. The CLI will now ask you to select the organization in which your Catalyst project that we created earlier in the console resides. Select the organization and press Enter.
catalyst-portal
  1. Select the project in the organization from the list and press Enter.
select-project
  1. Select Functions and Client using the space bar. Press Enter to initialize the components.
select-components
  1. The CLI will first initiate the function setup. Select Job as the function type.
job-function
  1. Select the latest runtime of Java as the function stack.
select-java
  1. Enter “NewsFetch” as the folder name and press Enter. Enter “FetchNews” as the class name and press Enter.
setup-function-java
  1. The CLI will now initialize the client set up. Choose “Basic web app” as the client type.
basic-web-app
  1. Enter ‘NewsAppClient’ as the name for the client package and press Enter. You can enter any name you want.
client-setup

The client directory will be created in the standard structure. Catalyst initialization is now complete.

Let’s now add an additional Advanced I/O function to the project directory. As mentioned earlier, we will be coding it in Node.js stack.

  1. To add an additional function, execute the following command from the project directory:
copy
$
catalyst functions:add
  1. Select AdvancedIO as the function type and press Enter.
advancedio
  1. Select the latest runtime of Java as the function stack, and press Enter.
advancedio-java
  1. Enter “NewsApp_AIO” as the folder name and press Enter. Enter “DatastoreFetch” as the class name of the Java function and press Enter.
advancedio-setup-java

The CLI will install the Catalyst Java SDK on your local system and update the information in the configuration file.

Note: Ensure that you enter the class name and folder name, exactly as instructed, because the application's code contains the same names.

Your project directory is now set up with the client directory and the functions directory along with configuration files and dependencies. The functions directory contains both the Job and Advanced I/O functions in individual folders. The project directory also contains the catalyst.json configuration file and a hidden catalyst.rc file.

The structure of the NewsApp project’s directory will look like this:

project-dir-java

Last Updated 2025-06-25 22:27:16 +0530 +0530