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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:46:38+00:00 2026-06-06T22:46:38+00:00

I am trying to write a small Java application that will let me run

  • 0

I am trying to write a small Java application that will let me run a Bukkit server off-screen using the Java Process/ProcessBuilder API.

I am able to get the output from the server fine, but the server doesn’t respond to commands written by the output stream returned by Process.getOutputStream() (chained to the process input stream).

I tried doing this with my own test code, and it worked. The separate process reading from System.in received the text written to the output stream.

Does Bukkit not listen to System.in or something?
If not, how can that be?
Any ideas?

try {
    ProcessBuilder pb = new ProcessBuilder();
    File dir = new File("C:/Users/Brian/Desktop/MC-Server/Bukkit-Testing");
    pb.directory(dir);
    pb.command(new String[] {"java", "-Xincgc", "-Xmx1G", "-jar", "craftbukkit-1.0.1-R1.jar"});
    pb.redirectErrorStream(true);
    final Process p = pb.start();
    InputStream out = p.getInputStream();
    BufferedReader r1 = new BufferedReader(new InputStreamReader(out));
    String s = null;
    new Thread(new Runnable() {

        @Override
        public void run() {
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
            Scanner scan = new Scanner(System.in);
            String input = null;
            while((input=scan.nextLine()) != null) {
                if(input.equals("exit")) {
                    p.destroy();
                    break;
                }
                try {
                    bw.write(input);
                    bw.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }).start();
    while((s=r1.readLine()) !=null)
        System.out.println(s);
} catch (IOException e) {
    e.printStackTrace();
}
  • 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-06T22:46:40+00:00Added an answer on June 6, 2026 at 10:46 pm

    I don’t think Bukkit uses its System.in, so we have to make a workaround.

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.logging.Logger;
    
    import org.bukkit.Bukkit;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class ConsolePlugin extends JavaPlugin {
    
        public Logger log;
    
        public void onEnable(){
            log = this.getLogger();
            log.info("BufferedReader has been enabled!");
            new Thread(new Runnable(){
                public void run(){
                    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                    String line = null;
                    while (true){
                        try {
                            line=br.readLine();
                        } catch (Exception e) {e.printStackTrace();}
                        if (line!=null){
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), line);
                            System.out.println(line);
                        }
                    }
                }
            }).start();
        }
    
        public void onDisable(){
            log.info("BufferedReader has been disabled.");
        }
    }
    

    To send commands:

    bw.write(input);
    bw.nextLine();
    bw.flush();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a small application using bouncycastle algorithm, from the BouncyCastleProvider.java
I am trying to write a small java program that will accept a file
I'm trying to write a small application that needs to use the clipboard for
I've been trying to write a small application which will work with mysql in
I'm creating a small server using java.nio , but when trying to stress test
I'm trying to write a small java program that connects to a twitter search
I'm trying to write a small utility service that will detect when a item(s)
I'm trying to build a small inventory application in Java, that switches views (or
I'm trying to write a really small program in Java that takes a string
I am trying to write a small Mac command line app that can read

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.