从Jar文件运行VM参数而不使用包装器

时间:2023-01-13 12:59:47

referring to this: Runnable jar with jvm args

指的是:带有jvm args的Runnable jar

I know it's possible to build/export a runnable jar from netbeans with embedded VM arguments. But i'm trying to move to eclipse and try stuff out. Is there any way to do this in eclipse without having to get an external launcher like a batch or wrapper?

我知道可以从带有嵌入式VM参数的netbeans构建/导出可运行的jar。但我正试图进行日食并尝试一下。有没有办法在eclipse中做到这一点,而无需像批处理或包装一样获得外部启动器?

EDIT: I tried having a second main class start the jar with the arguments and it's still doesn't seem to be working:

编辑:我尝试了第二个主类启动带有参数的jar,它仍然似乎不起作用:

    public static void main(String[] args) {

     try {
            Process exec = Runtime.getRuntime().exec("java -Dsun.java2d.opengl=true -splash:splash.png -jar Radiance.jar");
        } catch (IOException e) {

            e.printStackTrace();
        }

     }

1 个解决方案

#1


0  

The only way to do this is that have the default program, start a second program using your JAR with the desired VM arguments. i.e. the JAR is also your launcher program. You can have any number of main(String[]) in your JAR.

执行此操作的唯一方法是使用默认程序,使用带有所需VM参数的JAR启动第二个程序。即JAR也是你的发射器计划。您可以在JAR中包含任意数量的main(String [])。

#1


0  

The only way to do this is that have the default program, start a second program using your JAR with the desired VM arguments. i.e. the JAR is also your launcher program. You can have any number of main(String[]) in your JAR.

执行此操作的唯一方法是使用默认程序,使用带有所需VM参数的JAR启动第二个程序。即JAR也是你的发射器计划。您可以在JAR中包含任意数量的main(String [])。