Hallo Forum,
seit einiger Zeit grübel ich darüber, wie ich eine, in einem jar-Archiv liegende, lokale Datei via Desktop.browse öffnen kann.
Was kann ich da machen?
Im Voraus schon einmal vielen Dank für jeden Tipp!!
seit einiger Zeit grübel ich darüber, wie ich eine, in einem jar-Archiv liegende, lokale Datei via Desktop.browse öffnen kann.
Java:
public void startDesktopBrowser(){
Desktop desktop;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
try {
URI uri = null;
// ?????????????????????????
// __test 1__ : that works fine!
//uri = new URI("http://www.java-forum.org");
// __test 2__ : that does not work :-(
//File file = new File("test.html");
//uri = file.toURI();
// __test 3__ : that does not work :-(
//index.html is part of bla.jar,which is added to the BuildPath
uri = getClass().getResource("/index.html").toURI();
// ?????????????????????????
desktop.browse(uri);
}catch(IOException ioe) {
ioe.printStackTrace();
}
catch(URISyntaxException use) {
use.printStackTrace();
}
}
}
}
Was kann ich da machen?
Im Voraus schon einmal vielen Dank für jeden Tipp!!