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

  • SEARCH
  • Home
  • 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 8867407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:01:17+00:00 2026-06-14T17:01:17+00:00

Is there any special reason for the results of java -version going to stderr

  • 0

Is there any special reason for the results of java -version going to stderr?

For example, this command executed from Windows’ prompt line:

java -version > java_version.txt

leaves the file java_version.txt empty.

EDIT: The same happens with the help printed out after executing java.exe without any parameters.

EDIT: Just out of a sheer curiosity I checked whether it has been always like that and it turned out it actually has. java -version goes to stderr in JDK 1.1.8 and also in JDK 1.2.2, however the outputs of java.exe without any parameters do not.

  • 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-06-14T17:01:19+00:00Added an answer on June 14, 2026 at 5:01 pm

    Is there any special reason for the results of java -version going to stderr?

    AFAIK, there is no special reason. It is just how the java command was / is implemented. Probably all the way back to Java 1.0, though it would be very difficult to verify that.

    My brief investigation shows that this behavior is inconsistent with how most Linux commands behave … everything else I’ve tried uses stdout for version information. (After all, the version information is not "error" output.)

    Note however --version / -version options are a convention rather than something required by any formal standard. (The GNU coding standards state that commands should implement --version and that version info should be written to standard output. But POSIX standards don’t mention this, nor do the LSB standards.)


    What can / should you do?

    • It should be easy to capture stderr instead of stdout in your shell script or batch file.
    • There shouldn’t be any risk in doing this. Oracle cannot change the Java tool chains to send -version output to stdout without potentially breaking customer scripts. This is highly unlikely1.

    1 – Here is evidence of just how unlikely it is: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4380614. Note the "Resolution: Wont Fix" … and the final comment.


    UPDATE

    In Java 9, they introduced some new "version" command line options. If you run java -help 2>&1 | grep version against a Java 11 installation you will see the following:

    $ java -help 2>&1 | grep version
        -version      print product version to the error stream and exit
        --version     print product version to the output stream and exit
        -showversion  print product version to the error stream and continue
        --show-version
                      print product version to the output stream and continue.
    

    So if you are using Java 11 LTS or later, the solution will be to use --version rather that -version to get the version information.

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

Sidebar

Related Questions

Is there any special reason for having the class names java.util.Hashtable with a small
For some reason the Windows command prompt is special in that you have to
Is there any special function to parse a .conf file in php like parse_ini_file()
Can anyone please tell me is there any special requirement to use either EXTERN
i want that during marshelling special character should escape, is there any way to
NHibernate 2.1.0 references Spring 1.3.0. NHibernate 2.1.1 references Spring 0.0.0.2. Is there any special
For some complicated reason, I need to mark some Javascript as special, like this:
Possible Duplicate: Create Generic method constraining T to an Enum Is there any reason
Is there any functional difference in Python between a try statement and an if
Is there any way in Notepad++ (or even with another tool) to change the

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.