Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

Print via Command Line

Thread view: 
Philipp Ciechanowicz - 19 May 2004 12:11 GMT
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 - 19 May 2004 15:32 GMT
> Hello NG.
>
[quoted text clipped - 23 lines]
>
> Philipp Ciechanowicz

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

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

Signature

Song

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

Chris Smith - 19 May 2004 15:39 GMT
> 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.

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.