Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:56:04+00:00 2026-05-30T17:56:04+00:00

I’m trying to create an automated error reporting tool for our Java desktop app.

  • 0

I’m trying to create an automated error reporting tool for our Java desktop app. the idea is to make it as easy as possible for customers to send us error reports whenever our application crashes.

Using the Desktop.mail API, I am able to craft messages that can be easily edited and sent from our users, but I’m running into system limitations on several platforms (notably Windows 7 and MS Outlook, which most customers are using)

When I run the example code below, you’ll notice that the email message that is displayed truncates the included stack trace. I believe this has something to do with a maximum length of either command lines or URIs in the underlying systems.

Is there a better way to craft an email from an error report that is not subject to this limitation?

import java.awt.Desktop;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URI;
import java.net.URLEncoder;

public class Scratchpad {

    public static void main(String[] args) throws Exception {
        try {
            generateLongStackTrace();
        } catch (Error e) {
            URI uri = createMailURI(e);
            // this will correctly pop up the system email client, but it will truncate the message
            // after about 2K of data (this seems system dependent)
            Desktop.getDesktop().mail(uri);
        }
    }

    // Will eventually generate a really long stack overflow error
    public static void generateLongStackTrace() throws Exception {
        generateLongStackTrace();
    }

    public static URI createMailURI(Error e) throws Exception {
        StringBuilder builder = new StringBuilder();
        builder.append("mailto:foo@example.com?body=");
        // encodes the stack trace in a mailto URI friendly form
        String encodedStackTrace = URLEncoder.encode(dumpToString(e), "utf-8").replace("+", "%20");
        builder.append(encodedStackTrace);
        return new URI(builder.toString());
    }

    // Dumps the offending stack trace into a string object.
    public static String dumpToString(Error e) {
        StringWriter sWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(sWriter);
        e.printStackTrace(writer);
        writer.flush();
        return sWriter.toString();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:56:06+00:00Added an answer on May 30, 2026 at 5:56 pm

    there are length limitations wrt admissible urls in ie and the length of a windows command line (see here, here, here and here) – i seems you run into one of these (though i admit that i have not rigorously checked).
    however i think it’s a plausible assumption that even if you could worm your way around the said limits the length of a generic transmission buffer between desktop applications (unless you use a dedicated api for remote controlling the target app) will be restricted somehow without a loophole.

    therefore i’d suggest one of the following strategies:

    1. distribution through a web server.

      • upload the data to be mailed to a web server instead using the html form file upload technique.
        basically you have to forge a POST request a payload with content type set to ‘multipart/form-data’. your content will need some wrapper data to conform syntactically with this mime type.
      • the actual transmission can be instigated by means of the WinHttpRequest COM object under windows or the curl command line program from everywhere else.
      • server side processing can be delegated to a suitable cgi handler which eg. might produce a (short) link to download the data fom the web server.
      • this link may be part of the http response to the upload request or you generate it client-side in the proper format for publishing it on the web server unaltered.
      • pro:
        this scheme is feasible – i have repeatedly applied it in enterprise projects. data transmission can be secured through https.
      • con:
        requires a web server to implement
    2. send a mail using an attachment (for some details see here):

      • save the body of your message to some file on the desktop.
      • generate a mailto-link that references an attachment (instead of the bulk of your body)
      • any decent mail client will be able to show the attachment inline if it has some elementary mime type like ‘text/plain’.
        on windows platforms you set it by choosing the proper file extension (‘.txt’)
      • pro:
        simple
      • con:
        file system access on the client platform;
        untested (at least by me)

    good luck !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
We're building an app, our first using Rails 3, and we're having to build
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.