For Programmers: Free Programming Magazines  


Home > Archive > Java Help > May 2004 > Print via Command Line









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Print via Command Line
Philipp Ciechanowicz

2004-05-19, 8:31 am

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

2004-05-19, 11:32 am

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

2004-05-19, 12:33 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com