Hi All! I am trying to run a batch file �Mine.bat� from Java file �Helpme.java� I have written in batch file D:\ cd javadoc javac Myprog.java java Myprog But when I try to run it (�Mine.bat�) from �Helpme.java� by using,
String str[]={�Mine.bat�}; Process proc; try{ proc=Runtime.getRuntime().exec("str"); }catch(Exception e){ System.out.println("Exception is raised"); } The out put results in only the change of directory that is from c:\ it goes to D:\ and program stops instead of running whole Mine.bat, plz tell me what to do? My goal is to compile another java file that is �Myprog.java� from �Helpme.java�. Files contain in the following directories. C:\Mine.bat C:\ Helpme.java D:\javadoc\Myprog.java I am using Windows me I will wait for reply. bye
Alex Givant
Greenhorn
Joined: Nov 12, 2001
Posts: 23
posted
0
I don't know how it'll help you, but when you run bat file from other bat you should use "call filename.bat" instead of "filename.bat". Alex.
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
no I want to run a batch file from java file
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
can u plz send me the coding how to run a batch file from java file it is not working properly only directory is changed
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Does the bat file work if you run it by hand from the d:\javadoc directory?
"JavaRanch, where the deer and the Certified play" - David O'Meara
Mo Ibrahim
Greenhorn
Joined: Jul 10, 2001
Posts: 28
posted
0
The batch file would not have worked properly because of the reason that 'd:\'. It should be actually 'd:'. Then, the directory change will happen and rest will follow.
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
My batch file is at C:\ and My java file "Helpme.java" is also at c:\ I am compling the file" Helpme.java" from c:\ but "Helpme.java" file is not running my batch file"Mine.bat" the result is only the change of directory that is D:\ when I run it from hand that is by using mouse then it works ok. But not from "Helpme.java"'s codding. I am making a compiler and I am very desperate to solve this problem. thank you for ur consideration,
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
Originally posted by Mo Ibrahim: The batch file would not have worked properly because of the reason that 'd:\'. It should be actually 'd:'. Then, the directory change will happen and rest will follow.
No Ibrahim its also not working now the output is only a cursor blinking and prgram is stoped just like waitting for an IO operation.
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
Hi plz help me!! I am waitting for any solution!!
Mo Ibrahim
Greenhorn
Joined: Jul 10, 2001
Posts: 28
posted
0
Is your path setting the same when you run manually and from the java program?
Shahbaz Khan
Greenhorn
Joined: Nov 13, 2001
Posts: 10
posted
0
First of All Thank U Ibrahim for helping me Path setting are different means My batch file is located at C:\ and I am compling the java file from C:\ and in batch file it is written to compile and run a javafile which is located in D:\javadoc\ Thank u again very much for ur concern about my problem coz I was thinking that I am left alone by the java experts running this services.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.