在JAR中强制系统属性 [英] Force System Properties in a JAR

查看:73
本文介绍了在JAR中强制系统属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个类似于上一个问题的问题:

I currently had a problem similar to this previous question:

为什么我们的Java应用不会显示辅助监视器上的Windows?

答案是:

  • Dsun.java2d.d3d = false
  • Dsun.java2d.noddraw = true

因此,我创建了启动应用程序的快捷方式,

So I created my shortcut to launch the application as such:

C:\WINDOWS\system32\javaw.exe -Dsun.java2d.d3d=false  -Dsun.java2d.noddraw=true -jar <file name>

反正有强迫该应用程序在代码中使用它而不必使用参数吗?

Is there anyway to force that application to use that in code and not have to use parameters?

推荐答案

是的,您可以使用

Yes, you can use System.setProperty(property, value); at the beginning of your program. Eg:

public static void main(String[] args)
{
    System.setProperty("sun.java2d.d3d", "false");
    System.setProperty("sun.java2d.noddraw", "true");

    // Start your real application
}

这篇关于在JAR中强制系统属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆