I have a VirtualMachine from which I want to extract "classpaths". The VM in this case is launched using a RawCommandLineLauncher
.
The closest thing I could find is the VirtualMachine
method allClasses
, but I would like one step above that and get a list of class directories instead. Is this possible?
I tried:
- Obtaining a
ClassLoader
from the VM. Don't think this is possible. - Using the JDI implementation for this. Unfortunately the method is not public.
You can check and cast to a subinterface, PathSearchingVirtualMachine
Above example uses instanceof pattern matching, which is a newer language feature. If you're on an older version of Java then do a normal cast.