Discussion Locked

How to have java code close batch script??

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a .bat script that launces an .exe and a java app:
:BEGIN
start /d "c:\Program files\xyz" /b xyz.exe
C:\j2sdk1.4.2_01\bin\java -classpath class_path=".;C:\Program Files\xyz\abc\src" xyz_java.Application
:END

And i need to know how to have teh xyz_java.Application app close teh bat file on exit. Any one have any ideas?

neil30076@xcelventures.com

2 replies

by ina_royiitr

hi,
looking at the code snippet that u've posted , i see that the batch file is itself calling the Java Application, hence to close the batch file u'll have to execute the Java Application to completion and then automatically batch file would close. i am guessing that the problem is how to exit the Java Application so that it returns the control to the batch file and not the Operating system directly ?
i guess if there is no exception thrown the usual system exit would work fine.
if u have already found a solution to ur problem plz do tell me as i too have got stuck at a possibly similar point.My problem is i don't know how to convert Java Appliction program to an exe file so i can call it thru another program.Object defn is not helping.

by matt.asplin

I don't know what you are really trying to accomplish here, but if the requirement is to really just get rid of the DOS window, first launch your exe, then launch the java application with the javaw command (This allows it to run outside the context of the DOS prompt), and then just exit the DOS command with your batch script immediately after launching. If your requirement is to keep the DOS prompt up the entire time the java application is up for System.out information being printed to the DOS window, I don't know of any easy way.

This discussion is closed to new replies.