File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I call jboss run.bat from a java application?

 
David Chen
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, there:

I have a question about jboss start. Can I call run.bat from a stand alone java application? by using:



I did try several times, but no any luck, it totally hangs my application (of couse the jboss did not get started at all). I tried consume inputstream, and errorStream in separate threads, still not helps. So, If I'm not supposed to start jboss server from java application, then why? or is there any other work around to start jboss dynamically from application? how?

Thanks a lot in advance
David
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use this:

import java.util.*;
import java.io.*;

public class JBossStart
{
public static void main (String arg[]) {
try {
Runtime rt = Runtime.getRuntime (); // step 1

Process process = rt.execexec("cmd.exe C:/ C:/jboss-2.4.8/bin/run.bat"); // step 2

InputStreamReader reader = // step 3
new InputStreamReader ( process.getInputStream () );

BufferedReader buf_reader =
new BufferedReader ( reader ); // step 4.

String line;
System.out.println("Guru: JBoss started...");
while ((line = buf_reader.readLine ()) != null)
System.out.println (line);


}
catch (IOException e) {
System.out.println (e);
}
} // main

} // class RunTimeApp
 
David Chen
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Gurumurthy:

Thank you very much for your reply. However, as I said in my previous post, I did consume both inputstream and stderr stream. And some gurus from jboss, java forum found my problem. Actually jboss "run.bat" can not be called outside jboss/bin directory. So, just put my application class under bin directory and execute "run.bat", it works.

Thanks a lot again
David
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic