1.

Solve : Two commands on one line??

Answer»

Is there a way to write two dos commands on one line?

The problem I'm having is that I want to start a java file from a .bat file

It navigates to the folder and enters the command:

java blahblah

to open my blahblah.class file

the next line is:

exit

When running the batch file, the java GUI opens up, but the java command hangs over so the exit will not execute. I was hoping to put SOMETHING like:

java blahblah, exit

so both would run at the same time. But if there's another way, like inserting a break into a .bat file that I don't know about that would help too. Thanks!Using an ampersand may work:

java blahblah & exit

8-)

This will depend on whether JAVA interprets the ampersand as a meaningful character in which case you may have to use the escape character ^Thanks for the suggestion, unfortunately it didn't work.

I tried

java blahblah & exit
java blahblah & ^
java blahblah ^

then:

java blahblah
^

as soon as it hits the java part it GOES to the next line and has a blinky cursor until the GUI is closed.Actually I meant to escape the ampersand:

java blahblah ^& exit

JAVA may parse all the characters on the command line, in which case the command processor never gets control back to interpret the characters after the blahblah

When your program ends, does not it give control back to the calling program which should be the command processor?

Just a thought. 8-)Yeah java parses everything on the line with java on it because you can run multiple FILES that way.

So the ^& exit thing didn't work either.

When my program ends, it does give back control to the console, but the thing is that my program's GUI is pretty small so you can still see the console running in the background, which is kind of what I want to avoid.
I'm confused as to why java blahblah would open a Java GUI.

As an example, after the proverbial "Hello World" program is compiled and then run, it simply outputs it's message and returns control to the command processor. Run from a batch file, the processor would simply execute the next instruction.

Am I missing something? 8-)What is the purpose of the EXIT command after the JAVA command? And why do you think EXIT needs to be on the same line as the JAVA command?

Try each of these (and maybe combinations of each) to see if they give you the desired result:
Code: [Select]start java blahblahCode: [Select]javaw blahblahCode: [Select]java blahblah.classWell I'm not sure why, but the FOLLOWING worked:

start javaw blahblah
exit


What happens now is exactly what I want. The batch file opens up my java program (which has a GUI) and then the batch file closes, leaving the java window still up and running.

This way it's like they click an executable file and ran the program.

Thanks for all of the help folks.



Discussion

No Comment Found