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\\gswi n32c.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite - sOutputFile=" + str1;
System.out.println ("str = " + str);
Runtime.exec(str);
}
}
Please help.
Kirti
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\\gswi
System.out.println ("str = " + str);
Runtime.exec(str);
}
}
Please help.
Kirti
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As both of your salutions are same,I split the points to both of you.
thanx :-)
ASKER