Description of Java hs_err error log files

I wrote on how to understand hs_err files earlier on this blog. Let’s discuss the nature of hs_err files today.

Basically a hs_err files is what you get when something goes wrong during a local Java session. Local as in using a Java Virtual Machine (JVM) locally. The HotSpot VM is the default JVM for the Java SE plattform. Hence the name of hs_err files: HotSpot Error log.

Description of JVM error files

A hs_err log file is being created by the JVM when a fatal error occurs. It contains useful debugging options for the programmers of the crashed application and it is good practice to ship these files with every bug report.

Naming conventions of JVM error files

Each log file is named in a simple scheme:

hs_err<pid>.pid

<pid> stands for a system specific process id.

File system locations of JVM error files

This information refers to JVM versions >=1.5 on Linux/Unix systems only:
When a fatal error occurs the JVM prints a short error to STDOUT and writes all other debugging information to the hs_err file (naming convention above). It tries to write this file to the current working directory. If this fails, e.g. the current directory is not writable for the process, it tries to determine a temporary directory. If no temporary directory can be found it prints all debugging information to STDOUT.

This information refers to JVM versions >=1.5 on Microsoft Windows systems only:
In most cases the hs_err log file is written to the desktop of the current user.

The location of the hs_err log file can be customized. Please use the following JVM command line option:
-XX:ErrorFile=./hs_err_pid .log
This command line option is available since JDK 6 / Java SE 6 (”Mustang”).

What can i do with JVM error files?

Normal users should sent a bug report including the hs_err file to the programmer of the application. Software developers may use the script mentioned here and read the official Java Trouble-Shooting and Diagnostic Guide.

Did this article help you? Please leave a comment or subscribe to my feed to receive more tips about Java and other coding issues!

This entry was posted in my beloved code and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Posted March 26, 2009 at 12:45 am | Permalink

    How would you recommend preventing these files from appearing on a user’s desktop, or forcing the file to go to an out of the way location? I’m running Windows machines where this is happening.

    I’ve added to the runtime parameter: -XX:ErrorFile=C:\TEMP\hs_err_pid.log, but it didn’t seem to have any effect.

  2. stotti
    Posted March 26, 2009 at 1:58 am | Permalink

    Hi Jeff, can you please state the Java version you are using? The flag depends on the JVM version.
    Please comment again and I’ll see if I can help you out.

    Best regards
    Stotti

  3. Posted March 29, 2009 at 12:17 am | Permalink

    1.4.2_12. Unfortunately, a legacy piece of software requires that we not update to anything newer.

  4. stotti
    Posted April 10, 2009 at 2:43 pm | Permalink

    Thanks for the reply, Jeff. Sorry to answer you this late.

    In Java versions before 1.5 (such as v1.4.2) the JVM writes error logs to the current working directory of the application. So please check if the working directory of your app is the desktop, i.e. the application is being started from there.

    If the current directory is not writable the hs_err log is saved to the system temporary directory, which may be identified by a call to System.getProperty(”java.io.tmpdir”); If this method returns the desktop location, you could try to set it by calling System.setProperty(”java.io.tmpdir”, “C:\temp\”); directly from your code – if you have control over the legacy app. Otherwise try setting the global path for temporary files via Windows.

    Please comment again when it worked out or you need assistance.

    Best wishes
    Stotti

  5. James
    Posted September 11, 2011 at 4:14 am | Permalink

    This worked just fine just needed to go to the java console in control panel then java tab view button add the runtime parameter: -XX:ErrorFile=C:\TEMP\hs_err_pid.log
    apply and works perfectly
    thank you

One Trackback

  1. [...] [update] This information is related to developers only. If you have Java problems or want to know more about hs_err errror logs please refer to this more general post.[/update] [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>