Link to home
Start Free TrialLog in
Avatar of kirtirani
kirtirani

asked on

problem in running Runtime.exec command....

Hi,
I need to run a ghostscript command using java. For that I am using Runtime.exec command. when I compile the class get this error :-
java:22: non-static method exec(java.lang.String) cannot be referenced from a static context
Here is my code:-

import java.lang.*;
public class TestGS
{
   public static void main (String[] args)
  {
    String str;
    String str1;
    char c;
    String file1;
    String file2;
    String mainfile;
    file1="C:\\1.pdf";
    file2="C:\\2.pdf";
    mainfile="C:\\3.pdf";
    c= (char) 34;
    str1 = c + mainfile + c + " " + c + file1 + c + " " + c + file2 + c;
    System.out.println ("str = " + str1);
    str = "C:\\gs\\gs8.11\\bin\\gswin32c.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -  sOutputFile=" + str1;
    System.out.println ("str = " + str);
    Runtime.exec(str);
  }
}

Please help.
Kirti
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kirtirani
kirtirani

ASKER

thanks.... it works :-)
As both of your salutions are same,I split the points to both of you.
thanx :-)