Using the launch4j Gradle plugin
Especially when already using Gradle, it is easy to apply the launch4j plugin to fix this.
As in freecouch' answer, create a file myapp.manifest
with
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable"
uiAccess="False" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
then apply the Gradle plugin by adding to your build.gradle
plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.3'
}
launch4j {
mainClassName = 'com.mypackage.MainClass'
icon = "$projectDir/icons/icon.ico"
manifest = "$projectDir/myapp.manifest"
}
or, if using Kotlin Gradle DSL, to your build.gradle.kts
:
plugins {
application
kotlin("jvm") version "1.2.31"
java
id("edu.sc.seis.launch4j") version "2.4.3"
}
launch4j {
mainClassName = "com.mypackage.MainKt"
icon = "$projectDir/icons/icon.ico"
manifest = "$projectDir/myapp.manifest"
}
javaw.exe
! – Haber