473,466 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Opening web help page from menu

14 New Member
Hi

Need a bit of help here please to point me in the right direction.

I have a java class file here which i wish from a menu item to open a web page which contains a help page.


Expand|Select|Wrap|Line Numbers
  1. ]
  2. } else if (arg.equals(" Help Page")) {
  3.     } else if (arg.equals("BrowserControl")) {
  4.     parent.doconnect();
  5.  


Below is the java file that calls the web page this works fine for some reason I can’t call it from the previous java class file

Many thanks for any help

Keith

Expand|Select|Wrap|Line Numbers
  1. import java.io.IOException;
  2. /**
  3.  * A simple, static class to display a URL in the system browser. *
  4.  * Under Unix, the system browser is hard-coded to be 'netscape'.
  5.  * Netscape must be in your PATH for this to work.  This has been
  6.  * tested with the following platforms: AIX, HP-UX and Solaris. *
  7.  * Under Windows, this will bring up the default browser under windows,
  8.  * usually either Netscape or Microsoft IE.  The default browser is
  9.  * determined by the OS.  This has been tested under Windows 95/98/NT. *
  10.  * Examples:
  11.  * Note - you must include the url type -- either "http://" or
  12.  * "file://".
  13.  */
  14. public class BrowserControl
  15. {
  16.     /**
  17.      * Display a file in the system browser.  If you want to display a
  18.      * file, you must include the absolute path name.
  19.      *
  20.      * @param url the file's url (the url must start with either "http://"
  21. or
  22.      * "file://").
  23.      */
  24.     public static void displayURL(String url)
  25.     {
  26.         boolean windows = isWindowsPlatform();
  27.         String cmd = null;
  28.         try
  29.         {
  30.             if (windows)
  31.             {
  32.                 // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
  33.                 cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
  34.                 Process p = Runtime.getRuntime().exec(cmd);
  35.             }
  36.             else
  37.             {
  38.                 // Under Unix, Netscape has to be running for the "-remote"
  39.                 // command to work.  So, we try sending the command and
  40.                 // check for an exit value.  If the exit command is 0,
  41.                 // it worked, otherwise we need to start the browser.
  42.                 // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
  43.                 cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
  44.                 Process p = Runtime.getRuntime().exec(cmd);
  45.                 try
  46.                 {
  47.                     // wait for exit code -- if it's 0, command worked,
  48.                     // otherwise we need to start the browser up.
  49.                     int exitCode = p.waitFor();
  50.                     if (exitCode != 0)
  51.                     {
  52.                         // Command failed, start up the browser
  53.                         // cmd = 'netscape http://www.javaworld.com'
  54.                         cmd = UNIX_PATH + " "  + url;
  55.                         p = Runtime.getRuntime().exec(cmd);
  56.                     }
  57.                 }
  58.                 catch(InterruptedException x)
  59.                 {
  60.                     System.err.println("Error bringing up browser, cmd='" +
  61.                                        cmd + "'");
  62.                     System.err.println("Caught: " + x);
  63.                 }
  64.             }
  65.         }
  66.         catch(IOException x)
  67.         {
  68.             // couldn't exec browser
  69.             System.err.println("Could not invoke browser, command=" + cmd);
  70.             System.err.println("Caught: " + x);
  71.         }
  72.     }
  73.     /**
  74.      * Try to determine whether this application is running under Windows
  75.      * or some other platform by examing the "os.name" property.
  76.      *
  77.      * @return true if this application is running under a Windows OS
  78.      */
  79.     public static boolean isWindowsPlatform()
  80.     {
  81.         String os = System.getProperty("os.name");
  82.         if ( os != null && os.startsWith(WIN_ID))
  83.             return true;
  84.         else
  85.             return false;
  86.     }
  87.     /**
  88.      * Simple example.
  89.      */
  90.     public static void main(String[] args)
  91.     {
  92.         displayURL("http://www.javaworld.com");
  93.     }
  94.     // Used to identify the windows platform.
  95.     private static final String WIN_ID = "Windows";
  96.     // The default system browser under windows.
  97.     private static final String WIN_PATH = "rundll32";
  98.     // The flag to display a url.
  99.     private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
  100.     // The default browser under unix.
  101.     private static final String UNIX_PATH = "netscape";
  102.     // The flag to display a url.
  103.     private static final String UNIX_FLAG = "-remote openURL";
  104. }
May 26 '07 #1
4 1677
pbmods
5,821 Recognized Expert Expert
We'd love to help you, but you've posted this in the JavaScript forum.

I've notified a JavaScript moderator so we can get your post moved to a forum where it will receive more relevant exposure.
May 27 '07 #2
Guern1
14 New Member
Hi

Many thanks sorry I have posted to the wrong forum

Keith
May 27 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Moved to the Java forum.
May 27 '07 #4
JosAH
11,448 Recognized Expert MVP
Maybe I totally misunderstood your question but have you ever read about Sun's
Java Help System? Here's the link.

kind regards,

Jos
May 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
3
by: yup | last post by:
I was wondering if you know a way to have, let's say, you would click on a menu bar item (where something like file, edit, format, help options are on Microsoft Word) and instead of opening a...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
7
by: swapcool | last post by:
Hi, I am a page having a menu and a few frames life below. The links in menu open in F3 frame. I also have back/forward buttons in F1 frame. ________________________ ____________F1_________|...
28
by: timhaynes1985 | last post by:
Hi, I am very new to PHP so please go easy on me. I have a page with 2 divs next to each other, a menu in the left and content in the right. Now what I want to know, is it possible to chenge...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.