The Artima Developer Community
Sponsored Link

Java Answers Forum
Printer Access

2 replies on 1 page. Most recent reply: Aug 21, 2009 3:47 AM by Meenakshi Parimoo

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Jerry Nelson

Posts: 1
Nickname: azjerry
Registered: Mar, 2006

Printer Access Posted: Mar 11, 2006 10:31 AM
Reply to this message Reply
Advertisement
A Java application I wrote includes a method to print to my printer as follows

/**accepts a string as input and prints to printer
*/
void printThis(String thisString) {
try {
FileWriter out = new FileWriter("LPT1");
String printThis = thisString;
out.write(printThis);
//out.write(0x0D); // CR
out.close();
}
catch (IOException e) {
e.printStackTrace();
}
}

This worked fine in my old Windows 98 machine but refuses to function in my new XP system. I've tried, without success, changing the FileWriter parameter to "USB001" which seems to be the new printer port. I've also tried every other LPT and COM port with no luck. Any suggestions?


Hansraj Mishra

Posts: 1
Nickname: cyberhans
Registered: Apr, 2006

Re: Printer Access Posted: Apr 18, 2006 9:13 AM
Reply to this message Reply
dude, the thing is that your code comes in ring three of security, as per the new norms of windows XP... win NT based systems have disallowed all access to hardware ports, and so you need a "device driver". this can be avoided if you have a proxy listener at ring zero... example ones that are available, and which successfully work as proxies are porttalk and userport. try them!

bbye,
hansraj

Meenakshi Parimoo

Posts: 1
Nickname: mparimoo
Registered: Aug, 2009

Re: Printer Access Posted: Aug 21, 2009 3:47 AM
Reply to this message Reply
Hi

I am using the same program , its working fine when I am giving LPT1 port or Prn: but nw I want to print on some network printer or on a printer on other machine how am i supposed to do that ??
I tried giving IP address and comp and printer name bt its nt w2orking


Meenakshi

Flat View: This topic has 2 replies on 1 page
Topic: Unix utility Previous Topic   Next Topic Topic: how to insert selected dropdown list value in mysql

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use