B4J Question SLC error

elitevenkat

Active Member
Licensed User
Longtime User
I tried to wrap a jar file and got he following error. The library is listed in the b4j lib manager. however after selecting it does not allow me to create an instance (dim pb as PrintBill) in the code.

What could be the problem ?

\Program Files\Anywhere Software\B4J\B4J.exe\../libraries\jCore.jar;C:\Program Files\Java\jdk1.8.0_71\bin\..\jre\lib\jfxrt.jar;]
[-sourcepath, src]
[-b4atarget, D:\ABMATERIAL\Addon\PrintBill.xml]
[-b4aignore, org,com.android,com.example,com.hoho]
Ignoring: [org, com.android, com.example, com.hoho]
starting....
Working with class: PrintBill
No ShortName annotation found for class: PrintBill
finish: D:\ABMATERIAL\Addon\PrintBill.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***

B4X:
JAVA CODE


import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.print.PrintService;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.PageRanges;
public class PrintBill implements Printable{

   
   
    private static PrintService[] printService;
    private static String text;
   
    public PrintBill() {
    printService = PrinterJob.lookupPrintServices();
    }
   
    public static void main(String[] args) {
    /*Check lt = new Check();
    //lt.printString("Hello, this is working");
   
      PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new PageRanges(1, 1));
    aset.add(new Copies(1));
   
    PrinterJob printJob = PrinterJob.getPrinterJob();
    text="Hello";
    printJob.setPrintable(lt);
     
    try {
        //  printJob.setPrintService(printService[7]);
        //index of installed printers on you system
        //not sure if default-printer is always '0'
        printJob.print(aset);
        } catch (PrinterException err) {
        System.err.println(err);
        }*/
    }
   
    public void printString(String input) {
   
    text = input;
   
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new PageRanges(1, 1));
    aset.add(new Copies(1));
   
    PrinterJob printJob = PrinterJob.getPrinterJob();
    printJob.setPrintable(this);
   
    try {
    //  printJob.setPrintService(printService[7]);
    //index of installed printers on you system
    //not sure if default-printer is always '0'
    printJob.print(aset);
    } catch (PrinterException err) {
    System.err.println(err);
    }
    }
   
    public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
    Graphics2D g2 = (Graphics2D) g;
    g2.translate(pf.getImageableX(), pf.getImageableY());
    g.drawString(String.valueOf(text), 14, 14);
    return PAGE_EXISTS;
    }
  }
 
Top