Force system properties in JAR

I currently had a problem similar to the previous question:

Why does our Java application not display windows on the secondary monitor?

The answer should include:

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

So, I created a 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 a way to get this application to use this in code and not use parameters?

+4
source share
1 answer

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

 public static void main(String[] args) { System.setProperty("sun.java2d.d3d", "false"); System.setProperty("sun.java2d.noddraw", "true"); // Start your real application } 
+11
source

Source: https://habr.com/ru/post/1382355/


All Articles