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 6724045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:38:29+00:00 2026-05-26T09:38:29+00:00

The output of the following program differs depending on whether I have IntelliJ compile

  • 0

The output of the following program differs depending on whether I have IntelliJ compile it, or whether I compile it by hand from the command line. As far as I can tell, I have only one compiler and JVM on my machine.

public class OutputTest {

public static void main(String[] args) throws Throwable {
  System.out.println(" Java Version: " +
        System.getProperty("java.version") +
        " from " + System.getProperty("java.vendor"));
  String message = "Dźien Dobry. Jak się masz?";
  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  Charset charset = Charset.forName("UTF-8");
  PrintWriter pw = new PrintWriter(new java.io.BufferedWriter(
        new java.io.OutputStreamWriter(stream, charset)), true);
  pw.write(message);
  pw.close();
  System.out.println(stream.toString());
  System.out.println(java.util.Arrays.toString(stream.toByteArray()));
 }
}

Output when compiled in IntelliJ:

Java Version: 1.6.0_26 from Apple Inc.
Dźien Dobry. Jak się masz?
[68, -59, -70, 105, 101, 110, 32, 68, 111, 98, 114, 121, 46, 32, 74, 97, 107, 32, 115, 105, -60, -103, 32, 109, 97, 115, 122, 63]

Output when compiled from the command line:

Java Version: 1.6.0_26 from Apple Inc.
D≈∫ien Dobry. Jak siƒô masz?
[68, -30, -119, -120, -30, -120, -85, 105, 101, 110, 32, 68, 111, 98, 114, 121, 46, 32, 74, 97, 107, 32, 115, 105, -58, -110, -61, -76, 32, 109, 97, 115, 122, 63]

To be clear: The output depends on where the code is compiled. I also see the first answer if I have IntelliJ compile the code, but run it from the command line.

I am running MacOS 10.6.8.

Also, for what it’s worth: When I compile it from the command line in Linux, I get the same answer that the IntelliJ-compiled version gives.

  • 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-26T09:38:30+00:00Added an answer on May 26, 2026 at 9:38 am

    Check the platform encoding; you may need to specify the -encoding parameter on the command line to match what IntelliJ is doing. Without it it’ll use the default platform encoding, which may or may not match how IntelliJ behaves.

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

Sidebar

Related Questions

Can someone tell me how I can make the following output? I have a
The output from the following program is: Non-Static Static Non-Static Is this a compiler
I have a question regarding the output of the following program. The output is
Consider the following output from a Tomcat server under Eclipse: INFO: Initializing Coyote HTTP/1.1
I have the following output (via link) which displays the var_dump of some XML
In my current repo I have the following output: $ git branch -a *
The expected output of the following C program is to print the array elements.
I'm struggling to understand why nothing is output using the following: class Program {
I have the following C program: #include <fcntl.h> #include <termios.h> #include <stdio.h> int main()
Can anyone tell me why is 5 showing up in the following line when

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.