0

Sorry my bad English.

I am trying to start Apache HTTPD server from Java on Windows

   public static Process pp;

    @Override
    public void run() {
        try {

            Runtime run = Runtime.getRuntime();
            try {

                MyThread.pp = run.exec("usr/local/apache24/bin/httpd.exe");                
                BufferedReader in = new BufferedReader(new InputStreamReader(MyThread.pp.getErrorStream()));
                String line;
                while ((line = in.readLine()) != null) {
                    System.out.println(line);
                }

If Apache HTTPD will started without output to the console (without errors and warnings) then this code started Apache HTTPD server correctly (with two processes in RAM) and all work fine .

But if Apache HTTPD server has any output to the console, then this Java code can't start Apache HTTPD Server correctly. For example, if Apache HTTPD server will has output to the console

AH00112: Warning: DocumentRoot [C:/Art/Dropbox/OpenSource/MyGIT/myprivatesite/]
does not exist
AH00548: NameVirtualHost has no effect and will be removed in the next release C
:/Art/MyServer/usr/local/apache24/conf/httpd.conf:535

than Java starts only one process of the Apache HTTPD server and he is can't work.

How I can start Apache HTTPD server if he has any console output?

2
  • Why? Just install it as a service. You don't need Java for that. Commented Sep 14, 2012 at 10:03
  • I make my portable pack and I don'r want install the service Commented Sep 14, 2012 at 12:06

1 Answer 1

1

Did you try connect all 3 streams to console? I think the code looks quite good.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.