Closed kia closed 1 year ago
Hi @kia! Are you asking about Windows?
Hi @fvarrui,
i see this behavior also on a linux machine but in the first place we would need it for windows.
Ok, I guess you are using winConfig.exeCreationTool=launch4j
since it's the only option that doesn't group icons on the Windows task bar. You should know that winrun4j
and why
group app icons without any problem and no extra configuration.
But, if you want to keep using launch4j
, I couldn't figure out how JP can help you, but you can use JNA (Java Native Interface) to do the trick (as is explained here):
jna
dependency to your pom.xml
(since JNA is not included in JDK/JRE):<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.13.0</version>
</dependency>
SetCurrentProcessExplicitAppUserModelID
from shell32.dll
using JNA:import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
public class Main {
private static native NativeLong SetCurrentProcessExplicitAppUserModelID(WString appID);
static {
Native.register("shell32");
}
public static void main(String[] args) throws IOException {
String appID = Main.class.getName(); // here you can use whatever id you want, but it has to be unique
if (SetCurrentProcessExplicitAppUserModelID(new WString(appID)).longValue() != 0) {
throw new RuntimeException("Unable to set current process explicit AppUserModelID to: " + appID);
}
// start your app here
}
}
And that's all! This works for me.
I guess it goes without saying that if your app is cross-platform, this
Main
class only works on Windows, so you need a different one for Linux and/or Mac OS.
I hope it helps!
Thank you very much @fvarrui . It works. I added some code to avoid conflicts related to our Linux build.
static {
if (System.getProperty("os.name").startsWith("Windows")) {
Native.register("shell32");
}
}
public static void main(String[] args) throws IOException {
if (System.getProperty("os.name").startsWith("Windows")) {
String appID = "Unique-App-Name";
if (SetCurrentProcessExplicitAppUserModelID(new WString(appID)).longValue() != 0) {
throw new RuntimeException("Unable to set current process explicit AppUserModelID to: " + appID);
}
}
I'm submitting a… question
could the icons of several running instances of the application be grouped on the desk-bar?
Is it possible to group the icons created on desk when a javafx application is started several times? currently the icons are shown separately.