Java Question Compile library

victormedranop

Well-Known Member
Licensed User
Longtime User
hi i.m trying to compile this to library for use with b4x.
i'am using this amazon tool

https://www.b4x.com/android/forum/t...-libraries-without-eclipse.29918/#post-173756

this is the java code

B4X:
package android.pt;
import android.util.Log;
public class Cprinter {
 public static final String LOG_TAG = Cprinter.class.getName();
 static {
 try {
 Log.i(LOG_TAG, "load cprinter lib");
 System.loadLibrary("cprinter");
 } catch (Exception e) {
 Log.e(LOG_TAG, "can not load cprinter lib");
 e.printStackTrace();
 }
 }
 public native int openPrinter();
 public native int closePrinter();
 public native int getPrinterVersion(byte[] version);
 public native int setZoonIn(int widthZoonIn, int heightZoonIn);
 public native int setAlignType(int alignType);
 public native int setLeftMargin(int n);
 public native int setRightMargin(int n);
 public native int setLineSpacingByDotPitch(int n);
 public native int setWordSpacingByDotPitch(int n);
 public native int setPrintOrientation(int printOrientation);
 public native int setBold(int n);
 public native int setUnderLine(int n);
 public native int setInverse(int n);
 public native int printLF();
 public native int feedPaper(int n);
 public native int printString(String content);
}


everything works fine

Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file C:\Users\victo\Desktop\New folder\src\Cprinter.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, D:\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, D:\SimpleLibraryCompiler]
[-bootclasspath, C:\Program Files (x86)\Android\android-sdk\platforms\android-24\android.jar]
[-classpath, C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\B4AShared.jar;C:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\Core.jar;]
[-sourcepath, src]
[-b4atarget, D:\b4x_libs\cprinter.xml]
[-b4aignore, org,com.android,com.example,com.hoho]
Ignoring: [org, com.android, com.example, com.hoho]
starting....
Working with class: android.pt.Cprinter
No ShortName annotation found for class: Cprinter
finish: D:\b4x_libs\cprinter.xml


I see it on my library.

but when I try to define a like

B4X:
dim printer as cprinter

is not visible.

Please any one some help. or maybe it can be done with java object

thanks,

Victor
 

victormedranop

Well-Known Member
Licensed User
Longtime User
I add this lines and can see the functions inside the library,

B4X:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
@Version(1.0f)
@ShortName("Cprinter")
@Author("Victor Medrano")

but still not working. code I posted , the java source with provide by de company that sells this terminals.

I'm still looking for help.

victor
 
Top