Print via Command Line  
Author Message
Philipp Ciechanowicz





PostPosted: 2004-5-19 19:11:00 Top

java-programmer, Print via Command Line Hello NG.

I'm trying to write a tool which is able to print a PostScript documents via
the command line. The call I'm making is the following:

String s = "copy /b " + filename + " lpt1:";
rt.exec(s);

This is commented by the interpreter as follows:

java.io.IOException: CreateProcess: copy /b
J:\Tmp\KyoceraMita\PostScript\Philipp.prn.tmp lpt1: error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at PrintPostScript.print(PrintPostScript.java:82)
at PrintPostScript.main(PrintPostScript.java:38)

Error = 2 means, that the file or something else is missing. The problem is:
The same command typed into my command line (I'm using W2k3) produces the
desired result. What am I doing wrong? Thanks in advance,

Philipp Ciechanowicz


 
Yu SONG





PostPosted: 2004-5-19 22:32:00 Top

java-programmer >> Print via Command Line Philipp Ciechanowicz wrote:
> Hello NG.
>
> I'm trying to write a tool which is able to print a PostScript documents via
> the command line. The call I'm making is the following:
>
> String s = "copy /b " + filename + " lpt1:";
> rt.exec(s);
>
> This is commented by the interpreter as follows:
>
> java.io.IOException: CreateProcess: copy /b
> J:\Tmp\KyoceraMita\PostScript\Philipp.prn.tmp lpt1: error=2
> at java.lang.Win32Process.create(Native Method)
> at java.lang.Win32Process.<init>(Win32Process.java:66)
> at java.lang.Runtime.execInternal(Native Method)
> at java.lang.Runtime.exec(Runtime.java:566)
> at java.lang.Runtime.exec(Runtime.java:428)
> at java.lang.Runtime.exec(Runtime.java:364)
> at java.lang.Runtime.exec(Runtime.java:326)
> at PrintPostScript.print(PrintPostScript.java:82)
> at PrintPostScript.main(PrintPostScript.java:38)
>
> Error = 2 means, that the file or something else is missing. The problem is:
> The same command typed into my command line (I'm using W2k3) produces the
> desired result. What am I doing wrong? Thanks in advance,
>
> Philipp Ciechanowicz
>
>

I would use JNI by using "system()" in "stdlib.h"

I think "copy" is a command of the command interpreter

--
Song

More info.:
http://www.dcs.warwick.ac.uk/~esubbn/

 
Chris Smith





PostPosted: 2004-5-19 22:39:00 Top

java-programmer >> Print via Command Line Philipp Ciechanowicz wrote:
> I'm trying to write a tool which is able to print a PostScript documents via
> the command line. The call I'm making is the following:
>
> String s = "copy /b " + filename + " lpt1:";
> rt.exec(s);

[...]

> Error = 2 means, that the file or something else is missing. The problem is:
> The same command typed into my command line (I'm using W2k3) produces the
> desired result. What am I doing wrong? Thanks in advance,

IIRC, Windows' copy command is a feature of the command shell, and not s
separate program in its own right. For that reason, you can't call it
directly; you have to go through the command shell. Try invoking
cmd.exe, with parameters "/C" and then your entire String. Be sure to
use the version of Runtime.exec that takes command-line parameters in an
array, because you don't want it to tokenize your last parameter.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation