hello,
I would like to use browser launcher to launch a manual.html file from within my desktop application.
With external html-files, everything works fine, but I don't know how to do it with local files and a relative path. With a url file://../manual.html I cannot get it work.
I am really grateful for all kinds of help or advice.
Greetings
joe
PS: Currently I am using the fatjar plugin for eclipse to pack my program into a jar-File.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
for handling local files
try {
BrowserLauncher launcher = new BrowserLauncher(null);
File helpFile=new File("Help/introduction.html");//this is an example location
String urlString;
try {
//here i converted the relative path of the file to url and passing that url string.
urlString = helpFile.toURL().toString();
launcher.openURLinBrowser(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
catch (BrowserLaunchingInitializingException ex) {
ex.printStackTrace();
}
catch (BrowserLaunchingExecutionException ex) {
ex.printStackTrace();
}
catch (UnsupportedOperatingSystemException ex) {
ex.printStackTrace();
}
you can well handle local files like this.
Regards
Sai
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
worked out perfectly! I did not make this "file to url to string transformation", I always tried to make a ../../doe reference, which was not very succesfull.
Greetings, Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello,
I would like to use browser launcher to launch a manual.html file from within my desktop application.
With external html-files, everything works fine, but I don't know how to do it with local files and a relative path. With a url file://../manual.html I cannot get it work.
I am really grateful for all kinds of help or advice.
Greetings
joe
PS: Currently I am using the fatjar plugin for eclipse to pack my program into a jar-File.
for handling local files
try {
BrowserLauncher launcher = new BrowserLauncher(null);
File helpFile=new File("Help/introduction.html");//this is an example location
String urlString;
try {
//here i converted the relative path of the file to url and passing that url string.
urlString = helpFile.toURL().toString();
launcher.openURLinBrowser(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
catch (BrowserLaunchingInitializingException ex) {
ex.printStackTrace();
}
catch (BrowserLaunchingExecutionException ex) {
ex.printStackTrace();
}
catch (UnsupportedOperatingSystemException ex) {
ex.printStackTrace();
}
you can well handle local files like this.
Regards
Sai
Thanks a lot Sai,
worked out perfectly! I did not make this "file to url to string transformation", I always tried to make a ../../doe reference, which was not very succesfull.
Greetings, Joe