HTML document feedback to java

hi,
I am trying to load a HTML document into JEditorPane (for viewing only). The HTML document contains a TextField and a Button, is there a way to notify my application whenever the Button is pressed?
Thank You!

Wow, it must take quite some time to figure this out:
http://forum.java.sun.com/thread.jsp?thread=414212&forum=57&message=1885273

Similar Messages

  • Viewing a HTML document in my Java program

    Hi,
    My Java program has a JTextPane that can display plain text or HTML documents. This program can mark up certain parts of the document to draw the user's attention.
    However, I am having problems when it comes to marking up some of the HTML documents. When they are first loaded onto the JTextPane, they appear fine. When I then run the method to apply the mark up styles, I notice that the text turns the same color as the background after a certain point - making it impossible to see the document or markup.
    The HTML (or text) document on display is made into a StyledDocument. And this is how the View for the HTML documents is created:
    HTMLEditorKit htmledkit = new HTMLEditorKit();
    ViewFactory myHTMLViewFactory = htmledkit.getViewFactory();
    return myHTMLViewFactory.create(elem);
    Note that elem is an Element -.-
    - I tried modifying the color tags in the HTML document, but even when I made the text black and the background white, the text still goes white. If it's a black background, the text goes black, etc. The markup style is actually trying to turn parts of the text red - and it works almost all of the time, apart from these certain documents.
    - I then tried applying my own style whenever a HTML document is loaded in, in the hope that I could force the background white and text black, regardless of the tags:
    MutableAttributeSet att = new SimpleAttributeSet();
    StyleConstants.setForeground(att,Color.black);
    StyleConstants.setBackground(att, Color.white);
    doc.setCharacterAttributes(0, doc.getLength(), att, false);
    The resulting document display kept the original HTML background color, but wherever there was text it looked like someone had run a highlighter over it to change the background white and text black. Kinda ugly! And it still didn't work - come markup time this style was ignored after a certain point.
    - This is one of the HTML documents that causes the problem:
    <html>
    <head>
         <link rel="STYLESHEET" type="text/css" href="mystyle.css">
         <title>My Document</title>
    </head>
    In the body tag:
    <table>
    table here... this displays fine
    </table>
    And here is the problem point:
    <table width=100% cellspacing=0 cellpadding=0>
    <tr>
    <td>
    <table width=100% cellspacing=0 cellpadding=0 style="padding: 3px; padding-top: 6px; padding-bottom: 6px;">
    <tr>
    <td width=100% style=" padding-left: 6px; padding-right: 6px;">
    <table class=pane cellpadding=0 cellspacing=0>
    <tr>
    <td width=100% class=panetitlebox align=Center >
    This is the last text that gets displayed! After this sentence, text goes same color as background.
    </td>
    </tr>
    <tr height=100% valign=top>
    <td class=panebox colspan=2 align=Left style="padding: 0px; border: solid 1px; border-top: none;">
    <table width=100% cellspacing=0 cellpadding=0>
    <tr>
    <td class=content align=Left style="padding: 4px; background: transparent;">
    <b>Bold text that doesn't show</b> More text that doesn't show
    And so on....
    In the header tag of another HTML document that has the same problem, it says it is HTML version 4.0. I have looked up the Java API and found that the javax.swing.text.html package is still 'migrating' towards HTML 4.0 and only supports HTML version 3.2. (Even in the API for Java 1.5 beta, although I use Java 1.4.2)
    So I assume that Java just can't handle my documents! I also think that most of these HTML documents were generated by a program (I think I saw Frontpage in one of the document's meta tags), because when I make my own HTML it doesn't have the problem.
    But it would be nice if my Java program can support these documents, so does anyone have any suggestions as to how I could get these documents to display properly once I apply mark up styles?
    If I haven't explained something properly, I will clarify as it is a complicated program, and I've been driving myself crazy with this problem for several days!

    I was looking through the HTML document removing pieces of code to see where the problem was. I removed all code relating to styles, alignment, width, padding etc, with no luck. The document has several tables, many of them nested, so I added some comments to see where each started and ended. After I added the comments, I checked the document in my Java program again, ran the mark up styles, and it suddenly worked! So I removed each comment one by one, checking each time, until I found the one that made it work. I then tried typing in the same spot, adding an extra space, moving the <tr> tag onto the same line, but only the HTML comment made it work. Here is the part of the document where I added the comment (it's in bold)
    This is the last text that gets displayed! After this
    sentence, text goes same color as background.
    </td>
    </tr>
    <tr height=100% valign=top>
    <td class=panebox colspan=2 align=Left style="padding:
    0px; border: solid 1px; border-top: none;">
    <table width=100% cellspacing=0 cellpadding=0> <!-- This comment makes the document display fine after markup -->
    <tr>
    <td class=content align=Left style="padding: 4px;
    background: transparent;">
    <b>Bold text that doesn't show</b> More text that
    doesn't showDoes anyone know WHY this is happening? It's so weird. I thought if it was something more obvious, like styles, I could just get my program to remove them when reading in the document. But added HTML comments????
    Thank you ^_^

  • Advanced HTML Document use

    Ok, I'm using an HTML Document in my Java Applet Jabber client. Currently I'm using an HTML Document for the chat area. What I'm lacking is the ability to turn html on/off or put in text that contains actual HTML without parsing it out.
    I've tried replacing the < and > 's with > and < but to no avail. This simply removes the hats or whatever they're called and everything between them completely from the content of the document. I've tried using the whitespace attribute of css which also did not work. I've tried 'pre' tags, and I've tried closing the html tag and re-opening it. I tried changing the content type of the document. None of these have worked, they simply remove the html or the entire text altogether. I'm guessing I either have to modify the parser or play with the actual objects of the html.
    Here's how I'm inserting the html(this is the only way I could get it to work).
    int start = doc.getLength();
    chatPane.setCaretPosition(start);
    inserter = new HTMLEditorKit.InsertHTMLTextAction(null,"<font color='"+nameHTMLColor+"'>"+from+"</font><font color='"+messageHTMLColor+"'>"+Static.decodeChat(message, htmlEnabled)+"</font>",HTML.Tag.BODY,null);
    inserter.actionPerformed(new ActionEvent(chatPane,ActionEvent.ACTION_PERFORMED,null));
    int end = doc.getLength();
    chatPane.setCaretPosition(end);
    Thanks for your time.
    --Zephryl                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hehe... I did, "I've tried replacing the < and > 's with > and < but to no avail." Sorry, the forum decoded the escapes.

  • Confirm on - Scratch-resistant glass, oleophobic coating,Adobe Flash HTML,Radio Stereo FM,Java MIDP emulator,Scratch-resistant glass back panel,Audio/video player and editor,TV Out,Document editor (Word, Excel, PowerPoint, PDF)

    Kindly confirm on the following features of Iphone 4s..and advice me accordingly.
    Confirm on - Scratch-resistant glass, oleophobic coating,Adobe Flash HTML,Radio Stereo FM,Java MIDP emulator,Scratch-resistant glass back panel,Audio/video player and editor,TV Out,Document editor (Word, Excel, PowerPoint, PDF)

    You can easily compare any Nokia devices using the web sites, here is a comparison of the N8 from the Nokia UK site:
    http://www.nokia.co.uk/gb-en/products/compare/?action=productcompareaction&site=64060&products=23301...
    And similar from Nokia Developer:
    http://www.developer.nokia.com/Devices/Device_specifications/Comparison.xhtml?dev=Lumia_800,N8-00
    Some information may be incomplete at present, since some device details were kept secret until the final moment of the launch so the pages have been prepared withoug all of the data.
    Nokia Maps is available for Windows Phone at launch.
    Multi-Touch(TM) is the registered trademark of another company, however Windows Phone does feature the common touch features such as swiping, pinch-zooming and so on.
    If this or any post answers your question, please remember to help others by pressing the 'Accept as solution' button.

  • Display a document.html in a frame java

    how can I display a .html in a frame java ?
    could it be possible to obtain a object Graphics to put it then in the frame ?

    JEditorPane

  • Print html document

    Hi, I'm trying to print a html document with this following java code but doesn't works:
      public void onActionPrintEncuestaPDF(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionPrintEncuestaPDF(ServerEvent)
         try{
              Robot robot = new Robot();
              // Ctrl+P
              robot.keyPress(KeyEvent.VK_CONTROL );          
              robot.keyPress(KeyEvent.VK_P );          
              robot.keyRelease(KeyEvent.VK_CONTROL);
              robot.keyRelease(KeyEvent.VK_P );
              Thread.sleep(500);
              //Alt+U
              robot.keyPress(KeyEvent.VK_ALT );
              robot.keyPress(KeyEvent.VK_U );
              robot.keyRelease(KeyEvent.VK_ALT );
              robot.keyRelease(KeyEvent.VK_U );
              Thread.sleep(500);
              //entrée
              robot.keyPress(KeyEvent.VK_ENTER);
              robot.keyRelease(KeyEvent.VK_ENTER );
              Thread.sleep(500);
         catch(Exception e){  }
        //@@end
    This is not working because java.awt.Robot is a part of AWT package and intended for the client site, how I can make an action that when the
    client push the print button. Print the html document automatly.
    Regards,
    Gabriel

    I create into KM Content on portal a file called print.html and I put the following code:
    &#65279;<html>
      <head />
      <body onLoad="window.parent.focus(); window.parent.print();">
      </body>
    </html>
    Because window.paren.print(); printed the code of actual iFrame. And into Web Dynpro I created a button that call the following function.
    public void onActionPrintEncuestaPDF(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionPrintEncuestaPDF(ServerEvent)     wdContext.currentPrintElement().setAtrURL("/irj/go/km/docs/documents/print/print.html");
       //@@end

  • Document types show up twice when creating a new blank HTML document.

    I followed the below instructions for getting HTML 5 as a document type option  on CS4. Although I do have HTML 5 as an option now, my other stock CS4 document type options now show up twice in the menu. Any idea how to fix this?
    To add the HTML document type, however, you need to modify the file named MMDocumentTypeDeclarations.xml. Here’s how to do that:
    1. Find the configuration folder then navigate to the documenttypes folder. The Configuration folder can be found under the folder where you installed Dreamweaver.
    2. Find and make a backup copy of MMDocumentTypeDeclarations.xml (MMDocumentTypeDeclarations.xml.bak)
    3. Open MMDocumentTypeDeclarations.xml in your favorite text editor. If anything goes wrong, you can always get back to the default state by replacing your changes with the backup copy.
    4. Go to the end of the document and find the </documenttypedeclarations> tag and add the following lines just before the </documenttypedeclarations> tag:
    <documenttypedeclaration id="mm_html_5">
    <title>
    HTML5
    </title>
    <doctypedecl>
    <![CDATA[<!DOCTYPE HTML>]]>
    </doctypedecl>
    <rootelement>
    <![CDATA[<html></html>]]>
    </rootelement>
    <dtdcontext>html</dtdcontext>
    <dtdcontext>html5</dtdcontext>
    <dtdcontext>frameset_frame</dtdcontext>
    <dtdcontext>xslt</dtdcontext>
    </documenttypedeclaration>
    5. Save the document
    6. Restart Dreamweaver
    You should now have an HTML5 document type option when you create a new document.
    There was an issue with Dreamweaver CS4 that needed to be fixed in code to fully support HTML5 documents which is why upgrading to CS5 was recommended. In CS4, Dreamweaver’s definition of a well formed HTML document has a meta content type which isn’t required for HTML5 documents so, no matter what we do to CS4, any HTML document created by CS4 will have the following:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    Replace that line with this:
    <meta charset=utf-8">
    You’ll need to do this every time you create a new HTML5 document.
    Once you finish go to Preferences New Document and select HTML5 as default Doc Type...
    Thanks to:
    What I did was create a snippit of the meta and added it to my snippit's meta folder
    Jeff Booher
    Dreamweaver Engineering
    Thanks for your feedback. 

    Hi,
    I have done a test and I can reproduced your issue.
    I referred to the blog about Automatically create Word documents which include list fields:
    http://blogs.technet.com/b/brenclarke/archive/2009/04/15/automatically-create-word-documents-which-include-list-fields.aspx
    When I create a multiple line of text column in a list, I just choose Plain text, Then I solved the issue:
    Besides, here is a similar post, you can take a look at:
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/a7ab3a61-6643-4a47-a464-fe46b5db1558/rich-text-field-showing-html-code
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • Opening a html document in order to load a certain website (and login), results in opening the startpage(s) from FireFrox.

    we use a html document to automatically login out application. but when this document opens FireFox always opens the startpage. When FireFox is already running the html document works as intended.
    no problems with IE.

    Unfortunately, Java standard API can't handle PDF file as a distinct document.
    However, you could use a physical URLConnection to get any file content as
    a simple byte mass.

  • How to display html document returned by utl_http package (POST method)

    I am using oracle forms 10g, data base version is 10g.
    I have written a database procedure that calls utl_http package POST method and request returns an html document. How do display this html document from oracle form?
    Thank you
    Hema

    Here you have...
    A Full Web Browser Java Bean - Oracle Forms PJCs/Java Beans
    http://forms.pjc.bean.over-blog.com/article-26251949.html

  • How to fill out POST HTML forms from my Java Application?

    Hi -
    I am writing a little Java GUI program that will allow a user to fill out data from the GUI and then submit that data. When they submit the data (two text fields) I want to take the two text fields and submit them via the POST form method of a HTML document over the web.
    Here is what I got so far:
    host = new URL("http", "<my_address>", web port, "/query.html");
                InputStream in = host.openStream();
                BufferedInputStream bufIn = new BufferedInputStream(in);
                for (;;)
                    int data = bufIn.read();
                    // Check for end of file
                    if (data == -1)
                        break;
                    else
                        System.out.print ( (char) data);
                }What that code does is makes a URL, opens a stream, and reads the HTML source of the file at the specified URL. There is a form that submits data via the POST method, and I would like to know how to write data to specific forms and specific input types of that form.
    Then, I'd like to be able to read the response I get after submitting the form.
    Is this possible?
    Thanks,

    Here is how one of my e-books go about Posting
    I tryied in one of my projects and it works ok
    (Tricks of the Java Programming Gurus)
    There's another reason you may want to manipulate a URLConnection object directly: You may want to post data to a URL, rather than just fetching a document. Web browsers do this with data from online forms, and your applets might use the same mechanism to return data to the server after giving the user a chance to supply information.
    As of this writing, posting is only supported to HTTP URLs. This interface will likely be enhanced in the future-the HTTP protocol supports two ways of sending data to a URL ("post" and "put"), while FTP, for example, supports only one. Currently, the Java library sidesteps the issue, supporting just one method ("post"). Eventually, some mechanism will be needed to enable applets to exert more control over how URLConnection objects are used for output.
    To prepare a URL for output, you first create the URL object just as you would if you were retrieving a document. Then, after gaining access to the URLConnection object, you indicate that you intend to use the connection for output using the setDoOutput method:
    URL gather = new URL("http://www.foo.com/cgi-bin/gather.cgi");
    URLConnection c = gather.openConnection();
    c.setDoOutput(true); Once you finish the preparation, you can get the output stream for the connection, write your data to it, and you're done:
    DataOutputStream out = new DataOutputStream(c.getOutputStream());
    out.writeBytes("name=Bloggs%2C+Joe+David&favoritecolor=blue");
    out.close();
    //MY COMMENT
    //This part can be improved using the URLEncoder
    //******************************************************You might be wondering why the data in the example looks so ugly. That's a good question, and the answer has to do with the limitation mentioned previously: Using URL objects for output is only supported for the HTTP protocol. To be more accurate, version 1.0 of the Java library really only supports output-mode URL objects for posting forms data using HTTP.
    For mostly historical reasons, HTTP forms data is returned to the server in an encoded format, where spaces are changed to plus signs (+), line delimiters to ampersands (&), and various other "special" characters are changed to three-letter escape sequences. The original data for the previous example, before encoding, was the following:
    name=Bloggs, Joe David
    favoritecolor=blue If you know enough about HTTP that you are curious about the details of what actually gets sent to the HTTP server, here's a transcript of what might be sent to www.foo.com if the example code listed previously were compiled into an application and executed:
    POST /cgi-bin/gather.cgi HTTP/1.0
    User-Agent: Java1.0
    Referer: http://www.foo.com/cgi-bin/gather.cgi
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-type: application/x-www-form-urlencoded
    Content-length: 43name=Bloggs%2C+Joe+David&favoritecolor=blue
    Java takes care of building and sending all those protocol headers for you, including the Content-length header, which it calculates automatically. The reason you currently can send only forms data is that the Java library assumes that's all you will want to send. When you use an HTTP URL object for output, the Java library always labels the data you send as encoded form data.
    Once you send the forms data, how do you read the resulting output from the server? The URLConnection class is designed so that you can use an instance for both output and input. It defaults to input-only, and if you turn on output mode without explicitly setting input mode as well, input mode is turned off. If you do both explicitly, however, you can both read and write using a URLConnection:
    c.setDoOutput(true);
    c.setDoInput(true); The only unfortunate thing is that, although URLConnection was designed to make such things possible, version 1.0 of the Java library doesn't support them properly. As of this writing, a bug in the library prevents you from using a single HTTP URLConnection for both input and output.
    //MY COMMENTS
    When you doing URL encoding
    you should not encode it as one string becouse then it will encode the '=' signes and '&' signes also
    you should encode all the field names and values seperatly and then join them using '&'s and '='s
    Ex:-
    public static void addField(StringBuffer sb,String name, String value){
       if (sb.length()>0){
          sb.append("&");
       sb.append(URLEncoder.encode(name,"UTF-8"));
       sb.append("=");
       sb.append(URLEncoder.encode(value,"UTF-8"));
    }

  • Opening html document.

    Hi all,
    I am trying to use java code to open a html document called "about.htm". At the moment I have the following code:
    public AboutDialog(Frame parent)throws IOException
         Runtime rt = Runtime.getRuntime();
         Process p = rt.exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe  D:\\Work\\about.htm");
         }Although this code works the problem is if I transfer it to another PC which does not use Internet Explorer I want it to open using whatever the default program is (ie.Firefox).
    In other words I want to remove the line C:\\Program Files\\Internet Explorer\\IEXPLORE.exeAny help would be appreciated.

    FebTen wrote:
    Change the statement like this. It works
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("cmd.exe /C start C:\\Progra~1\\DinPro\\about.html");No, absolutely not the right way to do it. That is unreliable as it assumes the short name of "Program Files" is always "Progra~1", which is not necessarily true. If there happened to be a couple of folders named, for example, "Program Files" and "Programmers R Us", both of those would have short names like "Progra~1" and "Progra~2" (or somesuch), and you can't be certain which one will map to "Program Files".
    The true solution is to do as DrClap said.
    Process p = rt.exec("cmd.exe /C start \"C:\\Program Files\\DinPro\\about.htm\"");Alternatively (and a better way) you can use the various flavors of Runtime.exec, passing it an array of strings, and it will insert the correct quotation marks around the ones containing embedded spaces. Something like:
    String[] args = { "cmd.exe", "/C", "start", "C:\\Program Files\\..." };
    Process p = rt.exec(args);Check the API documentation.

  • Problem parsing a html document

    Hi all,
    I need to parse a html document.
    InputStream is = new java.io.FileInputStream(new File("c:/temp/htmldoc.html"));
    DOMFragmentParser DOMparser = new DOMFragmentParser();
    DocumentFragment doc = new HTMLDocumentImpl().createDocumentFragment();
    DOMparser.parse(new InputSource(is), doc);
    NodeList nl = doc.getChildNodes();
    I get just 3 of the following nodes...... though the document htmldoc.html is a proper html doc..
    #document-fragment
    HTML
    #text
    Any suggestions/help are most welcome. Thanks

    Here's an example showing how to do this via javax.xml:
    import java.io.*;
    import java.net.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    public class HTMLElementLister {
         public static void main(String[] args) throws Exception {
              URLConnection con = new URL("http://www.mywebsite.com/index.html").openConnection();
              con.connect();
              InputStream in = (InputStream)con.getContent();
              Document doc = null;
              try {
                   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   doc = db.parse(in);
              } finally {
                   in.close();
              NodeList nodes = doc.getChildNodes();
              for (int i=0; i<nodes.getLength(); i++) {
                   Node node = nodes.item(i);
                   String nodeName = node.getNodeName();
                   System.out.println(nodeName);
                   if ("html".equalsIgnoreCase(nodeName)) {
                        System.out.println("|");
                        NodeList grandkids = node.getChildNodes();
                        for (int j=0; j<grandkids.getLength(); j++) {
                             Node contentNode = grandkids.item(j);
                             nodeName = contentNode.getNodeName();
                             System.out.println("|- " + nodeName);
                             if ("body".equalsIgnoreCase(nodeName)) {
                                  System.out.println("   |");
                                  NodeList bodyNodes = contentNode.getChildNodes();
                                  for (int k=0; k<bodyNodes.getLength(); k++) {
                                       node = bodyNodes.item(k);
                                       System.out.println("   |- " + node.getNodeName());
    }

  • Need help in html that use in java

    I want to know .. can I open new frame and use the whole frame for a HTML document (located on the client) .. and can anyone give me an example or tell me where can I find the example.. I will use it in the system that build use JDK 1.3 or JDK 1.2

    Hi mutia
    If I understand you correctly, the code below is what you're looking for. It is just a crude example with a start screen with a help button, when you click on the help button, a new frame is opened and a string containing HTML tags is displayed. You can compile and test it like this:
    javac myFrame.java
    java myFrame
    myFrame.java
    =======================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class myFrame extends JFrame implements ActionListener {
       public static void main(String args[]) {
          myFrame frame = new myFrame();
          frame.pack();
          frame.setVisible(true);
       public myFrame() {
          setTitle("Main Frame");
          JPanel pan=new JPanel();
          pan.setLayout(new BorderLayout());
          pan.setPreferredSize(new Dimension (200, 100));
          setContentPane(pan);
          JButton helpButton = new JButton("H E L P");
          pan.add(helpButton);
          helpButton.addActionListener(this);
          addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
                System.exit(0);
       public void actionPerformed(ActionEvent e) {
          JFrame F=new JFrame();
          F.setTitle("Help Screen");
          JPanel pan=new JPanel();
          pan.setLayout(new BorderLayout());
          pan.setPreferredSize(new Dimension (200, 100));
          F.setContentPane(pan);
    * lab can be read in from a file but I'll leave that part up to you
          JLabel lab=new JLabel("<html><font size=+1 color=blue>This is a test help<br>message</html>");
          pan.add(lab);
          F.pack();
          F.setVisible(true);
    }V.V.

  • Open html document

    what can i do so that i can using java application to make browser open a html document
    thank you for your help

    public class BrowserControl
    public static void displayURL(String url)
    boolean windows = isWindowsPlatform();
    String cmd = null;
    try
    if (windows)
                        try
                             Runtime.getRuntime().exec("start iexplore \""+url+"\"");
                        catch (java.io.IOException e)
                             System.out.println("caught ioexception") ;          
                             //e.printStackTrace();
                             try
                                  Runtime.getRuntime().exec("cmd /c start iexplore \""+url+"\"");
                             catch(Exception ee)
                                  System.out.println("caught again ee") ;          
                                  ee.printStackTrace();
                                  // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
                                  cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                                  Process p = Runtime.getRuntime().exec(cmd);
    else
    // Under Unix, Netscape has to be running for the "-remote"
    // command to work. So, we try sending the command and
    // check for an exit value. If the exit command is 0,
    // it worked, otherwise we need to start the browser.
    // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
    cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
    Process p = Runtime.getRuntime().exec(cmd);
    try
    // wait for exit code -- if it's 0, command worked,
    // otherwise we need to start the browser up.
    int exitCode = p.waitFor();
    if (exitCode != 0)
    // Command failed, start up the browser
    // cmd = 'netscape http://www.javaworld.com'
    cmd = UNIX_PATH + " " + url;
    p = Runtime.getRuntime().exec(cmd);
    catch(InterruptedException x)
    System.err.println("Error bringing up browser, cmd='" +
    cmd + "'");
    System.err.println("Caught: " + x);
    catch(Exception x)
    // couldn't exec browser
    System.err.println("Could not invoke browser, command=" + cmd);
    System.err.println("Caught: " + x);
    * Try to determine whether this application is running under Windows
    * or some other platform by examing the "os.name" property.
    * @return true if this application is running under a Windows OS
    public static boolean isWindowsPlatform()
    String os = System.getProperty("os.name");
    if ( os != null && os.startsWith(WIN_ID))
    return true;
    else
    return false;
    * Simple example.
    public static void main(String[] args)
    displayURL("http://www.javaworld.com");
    // Used to identify the windows platform.
    private static final String WIN_ID = "Windows";
    // The default system browser under windows.
    private static final String WIN_PATH = "rundll32";
    // The flag to display a url.
    private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
    // The default browser under unix.
    private static final String UNIX_PATH = "netscape";
    // The flag to display a url.
    private static final String UNIX_FLAG = "-remote openURL";

  • Javadoc HTML document to contain external package information

    Hi there:
    I would like to know how to issue the proper command line to generate a javadoc html document containing external packages. I found the the -group option, can anyone provide some insights to this?
    I have one java source that use java.sql package, I like to be able to generated the html document to show everything associated with the java.sql package in addition to my own java program.
    Thanks, Joseph

    There are two ways to do this: (most people use the second approach)
    1) Include package and class pages for both your packages and the java.sql.package This requires that you have the java.sql
    source files and run javadoc on them both:
    javadoc -d docs -sourcepath <paths> com.yourpackage java.sql
    where <paths> is the paths to your package and java.sql
    source files (semi-colon separated on Windows).
    To get the source files for java.sql you might be able to use
    the source files in src.zip that comes with the J2SDK, but
    the package.html file is not included. You could re-construct
    that from the HTML page on our website (remove the table of
    classes from overview-summary.html), or just get the entire
    source release from:
    http://java.sun.com/j2se/javadoc/faq/index.html#sourcecode
    which has the complete source code.
    2) Include package and class pages for only your packages, and
    just links to existing java.sql documentation.
    javadoc -d docs -link <URL> -sourcepath <path> com.yourpackage
    where <URL> is http://java.sun.com/j2se/1.4/docs/api
    and <path> is the path to your source files.
    If your terminal window cannot ping that URL, then you must
    copy package-list from that location to your local drive and
    use -linkoffline instead (look up in the docs).
    -Doug Kramer
    Javadoc team

Maybe you are looking for

  • InDesign CS6 Keeps Crashing when I export pdfs or try to print! HELP

    I just updated to a new Mackbook Pro (10.7.4) which I put CS6 on. I am able to open/work and save files in InDesign but I am not able to print or export as a pdf. Here is my crash report: http://pastebin.com/VHD25kg5 Please help!

  • What Variables have been used in a Query???

    Hi All,   how can i find out what variables are being used by a particular standard query in Query Designer level. When we open a query in query designer on the left panel expanding a characteristic we can see what are the available variables in that

  • ABAP & JAVA Proxies

    Hi Experts, Can any one please tell me what are the prerequisites and connection settings that needs to be taken care while developing the ABAP/JAVA proxies. Thanks in advance. Regards, Shaily

  • HT4628 all looks good but I keep getting "a connection timeout occurred"

    Driving me crazy! I did the zap of PRAM recommended - 2x but to no avail. Will try again. Tech support for the ISP has said all looks good and that it's a problem with my computer. I guess I will head to the library to see if I can get online there -

  • Connect to different databases

    Hi all, I want to read data from a table t1 in a DB1 and write it in a table t2 in another database DB2 using Oracle forms 10g. Thanks Charbel