60

I am confused about the instruction when using Kinesis Video Stream

Run DemoAppMain.java in ./src/main/demo with JVM arguments set to

-Daws.accessKeyId={YourAwsAccessKey} -Daws.secretKey={YourAwsSecretKey} -Djava.library.path={NativeLibraryPath}

for non-temporary AWS credential.

How to set these arguments in IntelliJ IDEA?

Islam Hassan
  • 673
  • 1
  • 10
  • 21
Feihua Fang
  • 931
  • 1
  • 8
  • 15

4 Answers4

94

Intellij allows you to specify two types of arguments when running a Java program:

  • VM Options
    • Enables you to modify attributes of the JVM, including stack/heap memory allocation, system properties, GC flags, etc.
  • Program Arguments
    • Values entered here are passed into the String[] parameter of your main method when the program begins.

enter image description here

In the above image, we specify a single system property (under VM Options) named example that has a value of Hello World!.

We also specify two program arguments (under Program Arguments): Hello and World!.

After clicking either the Apply button or the OK button, we can run the following program:

public static void main(String[] args) {
    System.out.println(System.getProperty("example"));
    System.out.println(args[0] + " " + args[1]);
}

The output of this program is as follows:

Hello World!
Hello World!

To create a Run/Debug Configuration, see: Create and Edit Run/Debug Configurations

Jacob G.
  • 28,856
  • 5
  • 62
  • 116
  • 1
    any example for passing them? – Gaurav Dec 13 '19 at 12:43
  • 1
    @gaurav I’ll edit this answer later today to make it more clear. – Jacob G. Dec 13 '19 at 12:50
  • does VM options accept comma seperated list? Or spaces like on the command line? – Geoff Langenderfer Jan 15 '22 at 23:16
  • @GeoffLangenderfer - from the Intellij documentation: "Options are separated using spaces. If an option has spaces inside, enclose it in double quotes. If double quotes is a part of an option, escape them using backslash..." – Asencion Sep 26 '22 at 23:00
  • Modern Idea versions (as of 2023), have slightly changed the UI for configuring the VM options from the screenshot here. The screenshot in [m19v's answer](https://stackoverflow.com/a/67960821/1155209), is more descriptive in setting the VM options for the current Idea version. – jewelsea Jan 05 '23 at 00:30
79

Follow steps below if you have 2021.1.1 Community Version:

enter image description here

m19v
  • 1,800
  • 4
  • 11
  • 26
  • 1
    I am also working on using `Jep` in my Android app and found on the [IntelliJ docs.](https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options) that we could `help` on the top menu bar and `Edit Custom VM Options...`. I guess we can also add it here ? – Paul Lam Jul 04 '22 at 07:49
1

go to edit configuration and put

-Dserver.port=9006(required port no) 

in the VM options: and apply and run, it will work

NoobEditor
  • 15,563
  • 19
  • 81
  • 112
SuniiilSingh
  • 117
  • 1
  • 3
0

enter image description hereYou can add multiple VM arguments

-Dserver.port=8999 -Dapi.prediction.base.url=https://ags-qa-predictions.azur -Dlogging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG -Dspring.jpa.show-sql=true -Dspring.profiles.active=prod
sajeeth
  • 47
  • 2
  • 9