I just researched this a couple of days ago.  You might try this on a
Windows platform.

Attached are two files.  One is a Launcher class that launches a browser for
you and the other contains my notes after searching the web for this stuff.

Example Invocations:
        Launcher.launchBrowser("http://www.intellij.com/eap/downloads";);
        Launcher.launchBrowser("mailto:[EMAIL PROTECTED]";);

It also handles things like Telnet, too.  This truly is telling windows to
launch the application associated with the protocol...

Let me know if it works for you.

-sms


-----Original Message-----
From: Philip Miller [mailto:[EMAIL PROTECTED]]
Sent: Thu, January 31, 2002 10:47 AM
To: [EMAIL PROTECTED]
Subject: [Eap-list] Off topic: popping up an external browser


Hi,
I know this is a little off the topic of this list, but since I have no
major complaints or suggstions about Idea 2.5 (other than wanting
support for javadoc comments and renaming a property variable should
also rename setters and getters), I thought I would ask this question:
How does Idea pop up the browser for help?  I am not concerned with how
it determines the url.  Rather I want to know what java code I can use
to launch a new browser for a given url.  I have code (I think I first
saw it on JavaWorld's web site) that uses a system call with the command

cmd = "cmd.exe /c start " + url.toString();

But this does not bring up a new browser on top of the other windows
like Shift-F1 does in Idea.  I would appreciate any help on this.

Thanks,
Phil

-------------------------------------------------- 
DISCLAIMER 
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information.  If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof. 

E-mail transmission cannot be guaranteed to be secure or error-free.  The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY 

Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications. 

    


From:  http://www.javaranch.com/ubb/Forum2/HTML/001027.html
/* =================================================================
This class launches the appropriate browser for the operating system the program is 
running on. Currently, this file only supports two operating systems: Windows NT/2000 
and SunOS.

On Windows, rundll32.exe in the WINNT/system32 directory is used to launch the browser.
=================================================================
*/

// include necessary Java classes
import java.io.IOException;
import java.util.*;
import java.io.File;


public class StartBrowser
{
private static final String WIN_PATH = "rundll32";
private static final String 
WIN_FLAG = "url.dll,FileProtocolHandler";


// constructor
//
// input is a String containing the url to display.
//
public StartBrowser(String urltext)
{
// first, determine what operating system the client is using
String osName = System.getProperty("os.name");

// Windows?
if((osName != null) && (osName.startsWith("Windows")))
{
// launch the Windows web browser
System.out.println("Windows environment");
LaunchWindowsBrowser(urltext);
}
else
if((osName != null) && (osName.compareTo("SunOS") == 0))
{
// launch the SunOS web browser
System.out.println("SunOS environment");
LaunchSunOSBrowser(urltext);
}
else
{
System.out.println("ERROR!! Unsupported operating" +
"system!!");
}
}



// function to start the SunOS browser
// NOTE: a script file is used to launch the browser. I didn't 
// include the script file here. Refer to a Unix book to 
// learn how to write your own script file to find/launch 
// the browser. This code snippet shows you how to 
// execute that script file.
private void LaunchSunOSBrowser(String urltext)
{
String commandString = null;

commandString = "" + urltext;

System.out.println("commandString = '" + commandString 
+ "'");

try {
// launch the browser
Process proc = Runtime.getRuntime().exec(commandString);
}
catch(java.io.IOException err)
{
System.err.println("Could not invoke the browser, command 
= " + commandString);
System.err.println("Caught: " + err);
}
}



// function to start the Windows browser
private void LaunchWindowsBrowser(String urltext)
{
String commandString = null;

try {
// Command string used is: 
// 'rundll32 url.dll,FileProtocolHandler http://...' 
commandString = WIN_PATH + " " + WIN_FLAG + " " +
File.separator + urltext;

// launch the Windows browser
Process proc = Runtime.getRuntime().exec(commandString);
}
catch(java.io.IOException err)
{
System.err.println("Could not invoke the browser, command 
= " + commandString);
System.err.println("Caught: " + err);
}
}


// TEST FUNCTION ONLY
public static void main(String[] args)
{
StartBrowser browser = 
new StartBrowser("http://www.sun.com";);
}
}




----
Creating Shutdown, Restart and Logoff Icons

        For Shutdown, the command is C:\WINDOWS\RUNDLL.EXE user.exe,exitwindows

        For Restart, the command is C:\WINDOWS\RUNDLL.EXE user.exe,exitwindowsexec

        For Logoff, the command is C:\WINDOWS\RUNDLL.EXE shell32.dll,SHExitWindowsEx 0




------
http://www.mvps.org/vbnet/index.html?code/shell/shellexecute.htm



------
(From:  http://www.jsiinc.com/SUBI/tip4100/rh4162.htm )

4162 � How can I open a URL from the Windpws 2000 command line?
rundll32.exe url.dll,FileProtocolHandler http://www.jsiinc.com


OR
rundll32.exe url.dll,FileProtocolHandler http://www.jsiinc.com/reghack.ht%6D

OR
start www.jsiinc.com

OR
start www.jsiinc.com/reghack.htm
NOTE: Rundll32 doesn't like .htm or .html files, which is why .ht%6D works, %6D is the 
hexidecimal code for m.

NOTE: The above commands will use an existing browser window if one exists.

To always open a new browser window:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE" www.jsiinc.com


OR
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" www.jsiinc.com/reghack.htm
To open the browser window at a fixed location and size:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE" 
javascript:window.resizeTo(1194,960);window.moveTo(80,5);location.href="http://www.jsiinc.com/reghack.htm";
NOTE: rundll32.exe url.dll,FileProtocolHandler www.jsiinc.com also works.



-----
From:  http://www.michael-thomas.com/java/javaadvanced/platform/

String strCommand = "play.htm";
String strCmd = "rundll32 url.dll,FileProtocolHandler" + " " + strCommand;
Process p = Runtime.getRuntime().exec(strCmd);


-----
From:  http://www.rgagnon.com/javadetails/java-0014.html
PDF (Windows only)
[ShowPDF.java]
public class ShowPDF {
   public static void main(String[] args) throws Exception {
     Process p = Runtime.getRuntime().exec("showpdf.bat mypdf.pdf");
     p.waitFor();
     System.out.println("Done.");
     }
   }

[showpdf.bat]
rundll32 url.dll,FileProtocolHandler %1
 
------
From: http://www.netspace.net.au/~jabrown/approach/webfaq04301710.html
lngRtn = Shell("rundll32.exe url.dll,FileProtocolHandler mailto:"; & 
CurrentView.Body.emailfield.Text)

End Sub

Note that the mailto protocol also lets you insert the subject and a limited amount of 
text in the message body, but can't use it to send file attachments. Full details are 
in RFC2368 (search for this document on the web).



----

Attachment: Lanucher.java
Description: Binary data

Reply via email to