I am trying to start tomcat from within a simple java snippet but it is failing. I looked at the other questions and duplicated their answers but none worked.
What I'm doing is executing a command through the Runtime
:
Process process = Runtime.getRuntime().exec("startup.bat");
Please note that the command is simplified, I normally provide a fully qualified path, environment variables for CATALINA_HOME
and some CATALINA_OPTS
and made sure the system env variables are available.
What happens is that the process starts normally, but when it spawns the console it is immediately closed, as if Java itself kills it. I tried adding Thread.sleep(x)
to the main thread to see if keeping the application alive would let tomcat run but it didn't, the console still died even though the Java app kept running.
I even tried running Tomcat through an Ant
script to see if delegating to Ant
would work but again to no avail. Even trying through a third party .bat file didn't work
Please do not suggest Cargo, Maven or similar tools, I'm looking for a programmatic solution at the moment.