$ javac Main.java 
    Main.java:27: error: illegal static interface method call
        ProcessHandle.current().allProcesses().mapToLong(w->w.pid()).forEach(System.out::println);
                                            ^
      the receiver expression should be replaced with the type qualifier 'ProcessHandle'
    1 error

Why do I get "the receiver expression should be replaced with the type qualifier 'ProcessHandle'"?

What shall I do instead? Thanks.


import java.lang.System;
import java.io.File;
import java.io.IOException;
import java.util.stream.Stream;

public class Main {

    public static void main(String args[]){

    System.out.println("visible processes pids are: ");
    ProcessHandle.current().allProcesses().mapToLong(w->w.pid()).forEach(System.out::println);  

    }
}

1 Answers

0
rob retro On Best Solutions

What are You trying to achieve here? It doesn't seem to make much sense to ask for the current ProcessHandle and then use that to query allProcesses. Both of these are static methods. You probably want to just omit the ".current()".