Java 如何在 IntelliJ IDEA 中设置 JVM 参数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50938383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:53:27  来源:igfitidea点击:

How to set JVM arguments in IntelliJ IDEA?

javaintellij-ideavideo-streamingamazon-kinesis

提问by Feihua Fang

I am confused about the instruction when using Kinesis Video Stream

我对使用 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.

在 ./src/main/demo 中运行 DemoAppMain.java 并将 JVM 参数设置为

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

用于非临时 AWS 凭证。

How to set these arguments in IntelliJ IDEA?

如何在 IntelliJ IDEA 中设置这些参数?

I followed the documentation and found the "Run/Debug Configurations" and don't know what to do next.

我按照文档找到了“运行/调试配置”,不知道下一步该怎么做。

Any help?
Thanks!

有什么帮助吗?
谢谢!

采纳答案by Jacob G.

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

Intellij 允许您在运行 Java 程序时指定两种类型的参数:

  • 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.
  • 虚拟机选项
    • 使您能够修改 JVM 的属性,包括堆栈/堆内存分配、系统属性、GC 标志等。
  • 程序参数
    • String[]程序开始时,此处输入的值将传递到main 方法的参数中。

enter image description here

在此处输入图片说明

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

在上图中,我们指定一个单一的系统属性(在VM选项)命名example具有的价值Hello World!

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

我们还指定了两个程序参数(在程序参数下):HelloWorld!

After clicking either the Applybutton or the OKbutton, we can run the following program:

单击Apply按钮或OK按钮后,我们可以运行以下程序:

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

要创建运行/调试配置,请参阅:创建和编辑运行/调试配置

回答by SuniiilSingh

go to edit configuration and put

去编辑配置并把

-Dserver.port=9006(required port no) 

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

在 VM 选项中:并应用并运行,它将起作用