Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing data using Java in Linux/Unix

 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I have a requirement where i need to call the printer API directly via my Java code and print. I have some specific alignment for my data. My code is as follows..


When i run this class in Eclipse , it works fine. But when i run this application in Unix environment , it is not printing the data. Instead it prints some characters like some ip adresses and some font names. Have analysed and found it to because of the format with which the data gets printed. It prints in a RAW format. I need to print my data alike. Please help me. Either i need to change this format to TEXT or use CUPS to configure. Please guide me how can i set the dataType to TEXT in Java so that it will print the data correctly.
 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone help me out in resolving this. It's very urgent.
 
Henry Wong
author
Marshal
Pie
Posts: 21506
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karthik Suryanarayanan wrote:
When i run this class in Eclipse , it works fine. But when i run this application in Unix environment , it is not printing the data.



You have to give us more detail than that. Is it going to the same printer? Is it on the same machine? If not, using the same operating system?

If the only difference is it works from eclipse and not from the command line, then you just have to ensure that the command line is using the same jar and class files (and libraries) as the eclipse environment.

Henry
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please EaseUp. There is no such thing as "urgent" around here.
 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is no issue from calling JAVA AWT API to printer in windows machine.

Printer is connected to Unix server and we are able print the files properly using the lpr filename command in unix server but in Unix server when we call to printer from java AWT API from application it is printing the junk characters and some setting relating informations are being printed on the papers.
 
karthik Suryanarayanan
Ranch Hand
Posts: 121
Java Opera Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And regarding encoding , i got the following ones in my unix server.

Unix

System.getProperty("file.encoding") - 8859_1

Charset.defaultCharset() - ISO-8859-1
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic