My Java application, deployed via webstart, invokes a helper application. I want to start the helper application in a separate JVM with the the same classpath as the main application.
Without webstart, the system ClassLoader
provides an answer. With webstart, the system ClassLoader
provides the path to deploy.jar
only.
I found this, but it seems to be out of date. It refers to at least one method on internal API com.sun.deploy.cache.Cache
that has since vanished from Java 8u60. Perhaps there is another way.
Here is something that works (in Jython) with Java 8u66. Obviously, I would prefer a solution that does not depend upon internal APIs. But, perhaps that is not available.
import com.sun.deploy.cache.Cache as Cache
import traceback
classPath = []
for indexFile in Cache.getCacheEntries(False):
try:
cacheEntry = Cache.getCacheEntryFromFile(indexFile)
jarFile = cacheEntry.getJarFile()
if jarFile is not None:
classPath.append(jarFile.getName())
except:
traceback.print_exc()