Search code examples
javacygwin

Why would jps (the java VM lister) give different answers in cygwin than from cmd.exe?


When I run jps in cygwin, I only see jps itself listed:

$ /cygdrive/c/tools/java/jdk-11.0.9.1+1/bin/jps.exe
10712 Jps

Running the same command from a command prompt shows all my current java processes:

C:\>c:\tools\java\jdk-11.0.9.1+1\bin\jps.exe
14864 AdcBridgeApplication
17664 Bootstrap
11876 IgsimulatorApplication
11988 AirWatchSimApplication
22328 Jps
16876 Eclipse

Starting cygwin from within a Windows cmd window also prevents me from seeing the full list:

C:\>"\tools\java\jdk-11.0.9.1+1\bin\jps.exe"
14864 AdcBridgeApplication
17664 Bootstrap
11876 IgsimulatorApplication
11988 AirWatchSimApplication
21076 Jps
16876 Eclipse

C:\>\tools\cygwin64\Cygwin.bat

wrightm1@NAL10-CP2MP13 ~
$ /cygdrive/c/tools/java/jdk-11.0.9.1+1/bin/jps.exe
12732 Jps

I know that jps needs permissions to the running JVMs to list them, presumably starting cygwin from cmd.exe would inherit any permissions from the (working) cmd.exe process.


Solution

  • At least in regards to this issue, what @queeg said is not true.

    Given a Win32-native-styled valid TMP value (or, leave TMP empty but set a valid TEMP value), jps works.

    $ TMP="$USERPROFILE"'\AppData\Local\Temp' jps
    16464 org.eclipse.equinox.launcher_1.6.700.v20231214-2017.jar
    5984 Application
    16052
    25896 XMLServerLauncher
    27112 Jps