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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:38:23+00:00 2026-05-23T16:38:23+00:00

So I have a process (java commandline application) that is hidden with the output

  • 0

So I have a process (java commandline application) that is hidden with the output and input being redirected. I can read the output very easily and that works, but when I send a command it dosen’t work.

I think that I have determined that the input is not being redirected because:

(A) When I send WriteLine(//command here); Flush no command is acknowledged by the program

(B) When I unhide the cmd window (StartInfo.CreateNoWindow = false;) I can enter commands and run them (in the cmd window) even though the StandardInput is being redirected (StartInfo.RedirectStandardInput = true;)

Here is the code:

namespace bukkit
{
    public partial class Form1 : Form
{
    private static StringBuilder _txt = new StringBuilder();
    private static bool _scrolled = false;
    Process mncrft = new Process();

    public Form1()
    {
        InitializeComponent();

        mncrft.StartInfo.WorkingDirectory = Path.GetTempPath();
        mncrft.StartInfo.Arguments = "-Xmx512M -Xms512M -jar C:\\mncrft\\mncrft.jar";
        mncrft.StartInfo.FileName = "java.exe";
        mncrft.StartInfo.UseShellExecute = false;
        mncrft.StartInfo.RedirectStandardOutput = true;
        mncrft.StartInfo.RedirectStandardError = true;
        mncrft.StartInfo.RedirectStandardInput = true;
        mncrft.StartInfo.CreateNoWindow = false;
        mncrft.ErrorDataReceived += build_ErrorDataReceived;
        //mncrft.OutputDataReceived += build_ErrorDataReceived;
        mncrft.EnableRaisingEvents = true;
        //mncrft.StandardInput.NewLine = "\r\n";
        mncrft.Start();
        mncrft.BeginOutputReadLine();
        mncrft.BeginErrorReadLine();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        _txt.AppendLine("Starting Minecraft...");
    }

    private void Form1_Close(object sender, EventArgs e)
    {
        mncrft.Close();
    }

    static void build_ErrorDataReceived(object sender, DataReceivedEventArgs e)
    {
        string msg = e.Data;
        if (msg != null && msg.Length > 0)
        {
            _txt.AppendLine(msg);
            _scrolled = false;
        }
    }

    private void mainTimer_Tick(object sender, EventArgs e)
    {
        if (_txt.Length > 0)
        {
            txtOutput.Text = _txt.ToString();

            // scroll down
            if (_scrolled == false)
            {
                txtOutput.SelectionStart = txtOutput.Text.Length;
                txtOutput.ScrollToCaret();
                _scrolled = true;
            }
        }
    }

    private void Execute_Click(object sender, EventArgs e)
    {
        if (textBox1.Text.Length > 0)
        {
            mncrft.StandardInput.WriteLine(textBox1.Text);
            mncrft.StandardInput.Flush();
        }
    }
}
}

How can I redirect the input so that I can send commands?

Thanks,
Adam

P.S: If this is confusing, just put a comment down and I will gladly clarify.

Answered

Thanks to Tim,
Replace the following lines:

mncrft.StartInfo.FileName = "java.exe";
mncrft.StartInfo.Arguments = "-Xmx512M -Xms512M -jar C:\\mncrft\\mncrft.jar";

with:

mncrft.StartInfo.FileName = "java";
mncrft.StartInfo.Arguments = "-Xmx512M -Xms512M -jar C:\\mncrft\\bukkit.jar -nojline";
  • 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-23T16:38:24+00:00Added an answer on May 23, 2026 at 4:38 pm

    Ok, I was messing with this all day, and I found the answer. When you launch bukkit with your application you need to include ‘-nojline’ to your process Arguments. This makes bukkit’s inputs work correctly with the standardinput.

    https://github.com/Bukkit/CraftBukkit/commit/22a44d47ac48fb65bb61fb823c84bff9494f5033

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

Sidebar

Related Questions

I have a Java process that opens a file using a FileReader. How can
I have a very simple command line Java application that I wish to port
I have a Java process that runs in the background. How can I quickly
If you have a java.io.InputStream object, how should you process that object and produce
I have a process in Linux that's getting a segmentation fault. How can I
I have an external Windows .exe that is actually Java application: Running the .exe
I have a Java process that runs on a Windows server where I have
I have a shell script that launches a Maven exec:java process - exec mvn
If I start a process via Java's ProcessBuilder class, I have full access to
I have a Java method which starts up a Process with ProcessBuilder, and pipes

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.