How to launch from Eclipse in Low priority under Windows?

eclipse, java, taskmanager

Solution

I have the same problem on Windows--- launching subprocesses that use all the CPUs (thread-parallel jobs), yet I want good responsiveness in my Windows development environment.

Solution: after launching several jobs:

DOS cmd>> `wmic process where name="javaw.exe" CALL setpriority "below normal"`

No, this won't affect eclipse.exe process.

Java Solution: Insert this code into your CPU-intense programs to lower their own Windows priority:

public static void lowerMyProcessPriority() throws IOException {
    String pid = ManagementFactory.getRuntimeMXBean().getName();
    int p = pid.indexOf("@");
    if (p > 0) pid = pid.substring(0,p);
    String cmd = "wmic process where processid=<pid> CALL setpriority".replace("<pid>", pid);
    List<String> ls = new ArrayList<>(Arrays.asList(cmd.split(" ")));
    ls.add("\"below normal\"");
    ProcessBuilder pb = new ProcessBuilder(ls);
    pb.start();
}

Yes, tested. Works on Win7.

Problem

I'm running programs from Eclipse (on Windows) that eat a lot of CPU time. To avoid bogging down my whole machine, I set the priority to Low with the Task Manager. However, this is a cumbersome manual process. Is there a way Eclipse can set this priority automatically? EDIT: I realized that each particular launcher (Java, Python etc) has its own configuration method, so I will restrict this question to the Java domain, which is what I need most.

Original source