This discussion is archived
5 Replies Latest reply: Jul 2, 2013 12:24 AM by AjayGM RSS

Cannot find the cached resources(jars) downloaded through Java Webstart 1.6

srikanthm - oracle Newbie
Currently Being Moderated
Hi Experts,

With Java 1.5 the below api call was returning the absolute location of downloaded jar through webstart.

URL where = ClassName.class.getProtectionDomain().getCodeSource().getLocation();
/*
Value of URL where file://c:/users/.................../abc.jar"
*/

But from 1.6 this api is returning only the relative path (value of URL is "/lib/abc.jar")

Our app is heavily dependent on the location of downloaded jars and hence it would be difficult to modify the app code to not to look for the downloaded jars.

So I'm looking for a way to find the location of downloaded jars

Please advise..

Before posting here I tried suggestions posted in the below links

https://bugs.eclipse.org/bugs/show_bug.cgi?id=244311
http://stackoverflow.com/questions/6789357/get-jars-under-resources-within-jnlp-file-with-jnlp-api

I tried this code to obtain the url s of the downloaded jars, but it did'nt work.

DownloadService2 service = (DownloadService2)ServiceManager.lookup("javax.jnlp.DownloadService2");
DownloadService2.ResourceSpec alljars = new DownloadService2.ResourceSpec("http://localhost:8085/words/*", "*", DownloadService2.JAR);
DownloadService2.ResourceSpec[] results = service.getCachedResources(alljars);

for (DownloadService2.ResourceSpec spec : results) {
     System.out.println(" +++++++++++ DownloadService2 ++++++++ " + spec.getUrl());
}


Thanks,
Srikanth M

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points