Java Question b4a lib from .jar

George Anifantakis

Member
Licensed User
Longtime User
I have a jar file with drivers for printing via a bluetooth printer. I would like to use it through my application for printing. I cannot find any .java file to use it through Simple library compiler in order to create the b4a lib. Only .class files exist inside .jar.


I tried to create a wrapper in order to user it thru SLC. The below error occurred thru compilation:


Starting step: Compiling Java code.

javac 1.6.0_26

javac: directory not found: bin\classes

Usage: javac <options> <source files>

use -help for a list of possible options

Error


Attached the relevant files.
 

Attachments

  • MPT-II.zip
    5.3 KB · Views: 266

George Anifantakis

Member
Licensed User
Longtime User
You will need to write the Java file. This file is the "wrapper".

See for example the wrapper for Flurry SDK: [Tool] Simple Library Compiler - Build libraries without Eclipse

I saw that. I made the below actions using flurry example according the instructions.

1. Download flurry.jar file

2. Copy flurry.jar file inside Flurry/libs

3. Copy flurry.jar to my additional lib folder

The SLC compilation produce the below error:

Starting step: Compiling Java code.

javac 1.6.0_26

javac: directory not found: bin\classes

Usage: javac <options> <source files>

use -help for a list of possible options

Error

Attached the flurry example files
 

Attachments

  • Flurry.zip
    48.4 KB · Views: 279

George Anifantakis

Member
Licensed User
Longtime User
Now i exported .jar file according the path getting the below error

1st compilation


Starting step: Compiling Java code.
javac 1.6.0_26
javac: directory not found: bin\classes
Usage: javac <options> <source files>
use -help for a list of possible options


Error.

Pressing again the compile button i get the bellow

Starting step: Compiling Java code.
javac 1.6.0_26
C:\VS\BAS4AND\SimpleLibraryCompiler\Flurry\src\anywheresoftware\b4a\objects\FlurryAgentWrapper.java:3: package com.flurry.android does not exist
import com.flurry.android.FlurryAgent;
^
1 error


Error.

Thanks
 

George Anifantakis

Member
Licensed User
Longtime User
I downloaded the zip file you attached. The source file was not in the correct place. It should have been under src\<package>\
I fixed it and it compiled correctly.

The error you are seeing in the IDE means that you didn't copy the FlurryAgent.jar to the libraries folder.
I downloaded the zip file you attached. The source file was not in the correct place. It should have been under src\<package>\
I fixed it and it compiled correctly.

The error you are seeing in the IDE means that you didn't copy the FlurryAgent.jar to the libraries folder.

Thanks a lot for your support. Can you please tell me what's wrong with the attached SDK. I create s wrapper but error about the package occur during compilation. Something is wrong in the first import statement. I tried a lot with no success. Do you think that files are missing that i should request from the vendor ?. Also i notice that the .jar file name is different from the .class inside the package.
Thanks.
 

Attachments

  • MPTII.zip
    228.1 KB · Views: 265

George Anifantakis

Member
Licensed User
Longtime User
You should put the source file in:
src\anywheresoftware\b4a\objects (according to the package name).

I done that with no result. I got the below error:

Starting step: Compiling Java code.
javac 1.6.0_26
C:\VS\BAS4AND\SimpleLibraryCompiler\MPTII\src\anywheresoftware\b4a\objects\MPTII.java:3: '.' expected
import PRTAndroidPrint;
^
1 error

Error.

Something is wrong with the

import PRTAndroidPrint;

I think that the path or name is not correct. Have you tried to compile it?

Thanks.
 

George Anifantakis

Member
Licensed User
Longtime User
This line is incorrect. What is the class name?

First of all i would like to clarify that i haven't java knowledge so any help would be much appreciated.
As i saw inside .jar file there are .class files without any folder structure like in the flurry example. So i don't exactly know how to define this statement correctly. I tried a to build the structure getting with some info from the .project file inside .jar with no luck. That's why i asked if you think that i should request additional information or files from the vendor as long as this .jar file with the sdk document and an apk test app are the only files that they send me.

Thanks
 

George Anifantakis

Member
Licensed User
Longtime User
I see now. You don't need this import line at all.

You can use a Java editor such as Eclipse to write the wrapper code. It is easier. You can still build the jar / xml with SLC.

You mean i must use eclipse or i can use another text editor?

I removed the line and now i have the below:

package anywheresoftware.b4a.objects;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@Version(1.0f)
@Permissions(values={"android.permission.INTERNET"})
@ShortName("PRTAndroidPrint")
@DependsOn(values={"PRTAndroidPrint"})
@ActivityObject
public class MPTII {
public void PRTConnectDevice(String PrintName) {
PRTAndroidPrint.PRTConnectDevice(PrintName);
}
public void PRTFeedLines(int iNum) {
PRTAndroidPrint.PRTFeedLines(iNum);
}


}

I get the error below:

Starting step: Compiling Java code.
javac 1.6.0_26
C:\VS\BAS4AND\SimpleLibraryCompiler\MPTII\src\anywheresoftware\b4a\objects\MPTII.java:19: cannot find symbol
symbol : variable PRTAndroidPrint
location: class anywheresoftware.b4a.objects.MPTII
PRTAndroidPrint.PRTConnectDevice(PrintName);
^
1 error


Error.
 

George Anifantakis

Member
Licensed User
Longtime User
Thanks a lot. I tried a lot with no result. I will ask for a new one.

Their jar file seems to be broken. They probably just copied the class files without keeping the correct folder structure.

Hi ,

I received a new .jar file with the correct structure. I test it inside eclipse with no errors.
So i tried to compile the code below using SCL

package anywheresoftware.b4a.objects;

import defaultPackage.PRTAndroidPrint;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@Version(1.0f)
@Permissions(values={"android.permission.INTERNET"})
@ShortName("PRTAndroidPrint")
@DependsOn(values={"PRTAndroidPrint"})
@ActivityObject

public class MPTII {

public static PRTAndroidPrint mobileprinter=new PRTAndroidPrint();

public void PRTConnectDevices() {
mobileprinter.PRTConnectDevices();
}

}


I've got the below error

C:\VS\BAS4AND\SimpleLibraryCompiler\MPTII\src\anywheresoftware\b4a\objects\MPTII.java:3: package defaultPackage does not exist
import defaultPackage.PRTAndroidPrint;
^
1 error

The code and the import statement import defaultPackage.PRTAndroidPrint; inside eclipse does not produce any error like the previous package. I have to mention that the .jar file name is not the same with the class file name . I don't know if that has something to do with the error. The .jar file name is "PRTAndroidPrinterSDK.jar" the class name is "PRTAndroidPrint". Also i have copy the .jar file inside the lib folder and the additional libraries folder. I also tried to extract the .jar file with the full path inside the lib folder. Nothing.
Have i done something else wrong?
 
Top