Results 1 to 8 of 8
Thread: Web Page
- 11-11-2008, 07:20 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
- 11-11-2008, 09:09 PM #2
Not my own code, but I've used this class before:
Java Code:///////////////////////////////////////////////////////// // Bare Bones Browser Launch // ///////////////////////////////////////////////////////// import java.lang.reflect.Method; import javax.swing.JOptionPane; public class BareBonesBrowserLaunch { private static final String errMsg = "Error attempting to launch web browser"; public static void openURL(String url) { String osName = System.getProperty("os.name"); try { if (osName.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class}); openURL.invoke(null, new Object[] {url}); } else if (osName.startsWith("Windows")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { //assume Unix or Linux String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec( new String[] {"which", browsers[count]}).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser"); else Runtime.getRuntime().exec(new String[] {browser, url}); } } catch (Exception e) { JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage()); } } }
Java Code:BareBonesBrowserLaunch.openURL(urlStr);
- 11-13-2008, 07:03 PM #3
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
but how to close?
- 11-13-2008, 07:20 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
- 11-14-2008, 06:29 AM #5
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
I am talking about closing the opened Web Browser through Java.
Like:
BareBonesBrowserLaunch.openURL(urlStr);
to open.
.................................
to close it after the page is loaded,or after some given time.
Thanks
- 11-14-2008, 06:53 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
You cannot close an application using Java. Actually you cannot open an application either. In that above code you don't have open an application(ie: browser). Confused? In reality what happen there is, that code segment simply telling that browser what's being sent, actually content of the browser. Then browser decide how to execute that. Nothing related or nothing to do with Java in that sense.
- 11-14-2008, 07:36 AM #7
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
so in that sense,Java is not so powerful rite?
so I have no way to control applications?
It is possible so many popular softwares right?
so not even an experienced Software Engineer can do this?
Thanks for your help.
- 11-14-2008, 08:55 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Similar Threads
-
Go back to previous page using session in JSP page
By gopikarikati009 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-23-2011, 11:30 AM -
setting the view to a jsp page from a self refeshing page
By deepal_205 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-15-2008, 05:41 PM -
i click on it,then first time error page comes,second time click then product page co
By 82rathi.angara in forum New To JavaReplies: 21Last Post: 08-01-2008, 12:13 PM -
warning that page has expired and i need to refresh the page again
By 82rathi.angara in forum JavaServer Pages (JSP) and JSTLReplies: 5Last Post: 07-15-2008, 02:48 PM -
help with jsp page
By praveena in forum New To JavaReplies: 3Last Post: 02-05-2008, 12:08 PM
Bookmarks