Program is getting hanged
This is my Batch file
@echo off
cls
echo Input File : %1.xml
echo Output File : %1Converted.xml
D:\Tool\converter\executables\exe\amp.exe %1.xml
set CP=\\ ... \saxon8-jdom.jar;\\ ... \saxon8-sql.jar;\\ ... \saxon8sa.jar;\\ ... \saxon-license.lic
java -cp %CP% net.sf.saxon.Transform -o %1Converted.xml %1.xml D:\ ... \xslFile.xsl
:exit
@echo on
In the above batch file, thexslFile.xsl is converting1.xml to1Converted.xml. If I run this batch file manually, the needed1Converted.xml is getting created from1.xml without any problem. But if I execute the same batchfile through my following code, my program is getting hanged. Could anyone please tell me where am I wrong.
This is my source code
publicstaticvoid main(String args[])
{
File xmlFile=new File("D:\\temp\\filename.xml");
String xmlFile1=xmlFile.toString();
String xmlFile2=xmlFile1.substring(0,xmlFile1.lastIndexOf("."));
Main m =new Main();
m.finalExe3(xmlFile2);
}
publicvoid finalExe3(String inputfile)
{
File file =new File(inputfile);
File fil =new File(file.getParent());
Runtime rt = Runtime.getRuntime();
try
{
String tempiso ="cmd /c D:\\temp\\batchfile.bat \""+inputfile+"\"";
Process procsrniso = rt.exec(tempiso, null, fil);
System.out.println("Executing FinalUpd..........."+inputfile);
String processline;
DataInputStream srnisoexelineip1 =new DataInputStream(procsrniso.getInputStream());
try
{
processline="";
String out="";
while ((processline = srnisoexelineip1.readUTF()) !=null)
{
out+=processline+"\n";
System.out.println(processline);
}
if(out.length()>0)
{
System.out.println(out);
}
}
catch (IOException e)
{
System.out.println("Error Fetching Information From batchfile.bat");
System.exit(0);
}
procsrniso.waitFor();
if(procsrniso.exitValue()==0)
{
DataInputStream srnisoexelineer =new DataInputStream(procsrniso.getErrorStream());
try
{
processline="";
String out="";
while ((processline = srnisoexelineer.readUTF()) !=null)
{
out+=processline+"\n";
System.out.println(processline);
}
if(out.length()>0)
{
javax.swing.JOptionPane.showMessageDialog(null,"Final Update Execution Problem \n"+out);
}
}
catch (IOException e)
{
System.out.println("Error Executing Final Update");
System.exit(0);
}
processline="";
}
else
{
DataInputStream srnisoexelineer =new DataInputStream(procsrniso.getErrorStream());
try
{
processline="";
String out="";
while ((processline = srnisoexelineer.readUTF()) !=null)
{
out+=processline+"\n";
System.out.println(processline);
}
if(out.length()>0)
{
javax.swing.JOptionPane.showMessageDialog(null,"Final Update Execution Problem \n"+out);
}
}
catch (IOException e)
{
System.out.println("Error Executing Final Update");
}
}
}
catch (Exception e)
{
System.out.println("Error at Final Update file Execution.");
}
}

