VNIT

Too lazy to think of a slogan

Trang chủ » Diễn Đàn » Lập trình và Phát triển Web » Java » How to use window shared printer on unix java program

Chủ đề đã bị khóa, bạn không thể xóa, sửa hay trả lời trong chủ đề này!

First Page Previous Page  1  Next Page Last Page
Locked How to use window shared printer on unix java program
0
question Gởi bởi phuongt (6:00 12-05-2011)
Bài: 1,736 / Điểm VCS: 1,686 /

I use FileOutputStream to open window shared printer.
on window :
FileOutputStream fos = new FileOutputStream("\\mymachine\printershare");
It is ok but on Unix it fails

I know I have to use SAMBA to mount that printer but have no idea.
Anybody has experience How to use window shared printer on unix please point me out.

Thank you very muchuch
Locked Re: How to use window shared printer on unix java program
0
answer Gởi bởi Thành Bá Nguyễn (22:58 12-05-2011)
Bài: 18,319 / Điểm VCS: 17,795 /

I use FileOutputStream to open window shared printer.
on window :
FileOutputStream fos = new FileOutputStream("\\mymachine\printershare");
It is ok but on Unix it fails

I know I have to use SAMBA to mount that printer but have no idea.
Anybody has experience How to use window shared printer on unix please point me out.

Thank you very muchuch

Tôi chưa thử share máy in trên Win cho Linux lần nào. Nhưng nếu mà cần phải share mới in được thì tôi nghĩ bạn đầu tiên nên hỏi ở box Linux đã. Mà tôi nghĩ dù gì đầu tiên bạn cũng nên cài gói Samba vào máy để mount được 1 share folder trên Win trước.
Ngoài ra bạn có thể tham khảo 1 số link sau: http://raldztech.blogsp...xp-printer-to-linux.html
Locked Re: How to use window shared printer on unix java program
0
answer Gởi bởi phuongt (3:19 13-05-2011)
Bài: 1,736 / Điểm VCS: 1,686 /

I set-up the Unix printer queue already. it named as d329
if I issue the command as "lp -d d329 /usr/local/javapost/textfile" then it will print out on my window shared printer.

What I want is how to open that queue (d329) in java program
I use

FileOutputStream fos = new FileOutputStream("d329");
  PrintStream ps = new PrintStream(fos);
  ps.print(s);
  ps.close();

it doesnot work, it create new file as d329.
Locked Re: How to use window shared printer on unix java program
0
answer Gởi bởi Thành Bá Nguyễn (3:57 13-05-2011)
Bài: 18,319 / Điểm VCS: 17,795 /

Printing in Java: http://www.javaworld.co...-2000/jw-1020-print.html
Locked Re: How to use window shared printer on unix java program
0
answer Gởi bởi phuongt (8:49 13-05-2011)
Bài: 1,736 / Điểm VCS: 1,686 /

I check the link and it is not what I want.
Program on window in order to print is not problem at all.

Problem is java on AIX (Unix)
I can execute Unix command "lp -D d329 pathtoTextfile" to print on java
but it only prints Text.
What I want is to print label on Zebra printer with EPL RAW CODE means I need to use data stream.

In java on Unix platform, is there any code to open shared printer or file located on Windows?

At the end I find a solution to make it works.
1/ Create a print queue on AIX (Unix)
2/ Process proc = Runtime.getRuntime().exec("lp -d" + queueName + " -o -dp -");
  OutputStream fos = proc.getOutputStream();
  PrintStream ps = new PrintStream(fos);
  ps.print(s);
  ps.close();
3/using generic/text for Zebra

so from Unix you can send EPL RAW CODE to window Zebra shared printer via print queue on AIX.
I think maybe someone can benefit from that code.

Enjoy
Locked Re: How to use window shared printer on unix java program
0
answer Gởi bởi Thành Bá Nguyễn (23:08 15-05-2011)
Bài: 18,319 / Điểm VCS: 17,795 /

Java's approach is cross-platform, so if you are looking for "Printing on Linux (either local or shared printer)" then I feel you are approaching the wrong way.

Anyway, if your solution works then fingers cross :-)
First Page Previous Page  1  Next Page Last Page

Thống kê

Hiện tại web site có 85,801 thành viên. Xin chào đón thành viên mới nhất meocon_th_90.

Các thành viên đã tạo 62,791 chủ đề và 241,917 bài viết trong 30 box.

Hiện có 0 thành viên và 1 khách đang trực tuyến.

Template by styleshout / Icons by Tango Icon Library and FamFamFam.