(Updated January 29, 2025)
Overview
Using an IDE to build and run programs is typically only done during development. Many developed programs will run on servers without a text or GUI interface of any kind and will write errors and such to log files for review when something goes wrong.
Since these programs are often executed from scripts that invoke them through the JRE behind the scenes, a mechanism needs to be in place to pass additional information to the program. This is where the command-line interface comes into play.
Review – Arrays of Objects
In Chapter 9, there is a section on Arrays of Objects that touches on how to use args
to get access to the data passed to the program.
As an application developer, you will need a method to simulate this from your IDE. This was done very quickly with IntelliJ IDEA.
From within IntelliJ, you will:
- Select Run from the top menu.
- Select Edit Configurations.
If there is a configuration already, change the Program Arguments and set them to the necessary values, and you’re done.
If you see
Select Add New Run Configuration, then select Application
Once that’s done, fill out the following values:
- Name
- Main class
- Program Arguments
Select OK to save the configuration.