Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force System Properties in a JAR

Tags:

java

jar

swing

I currently had a problem similar to this previous question:

Why would our Java app not display windows on secondary monitor?

The answer was to include:

  • 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?

like image 844
Halfwarr Avatar asked Dec 22 '22 06:12

Halfwarr


1 Answers

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
}
like image 57
Martijn Courteaux Avatar answered Jan 07 '23 20:01

Martijn Courteaux