B4J Question How to refer to types, inside an external jar?

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

What is the syntax to refer to a library reference, in order to make use of a type defined in an external library?

I already have the path specified in Additional Libraries, and the specific jars indicated with the #AdditionalJar: directive. But how do you refer to the external jar, so that the As (Type) reference will compile?
 

B4JExplorer

Active Member
Licensed User
Longtime User
... or at least forward an example of a b4j module that refers to additional jars in the auxiliary library folder, and makes use of its classes. This may sound easy & obvious to everyone using B4A or B4J for a while, but I can't figure out how to do it. I need to use several external libraries.

There are very few results, from a additionaljar search on the forum, or from a 'b4j additionaljar' search, in Google.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
If I understand you correctly, you want to know how to refer to a class in an external library.

As far as I understand, when you use the syntax

Dim something AS myClassInMyLibrary

B4J automatically calls the constructor for it PROVIDING it takes no parameters.

The shortname directive in the library is what appears on the 'lib' tab of the IDE (remember to tick the box if you want to use the library)
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Even if I use the exact class name, which is included in one of the jars referenced in the additionaljar directive, B4J won't compile. The error message asks if I'm missing a library reference?

I don't understand this. The library reference is already given in the additionaljar line. Where else would we put it?


Daestrum, I think you're referring to the libraries in the (Program Files)\(Anywhere Software)\B4J\Libraries folder.

I'm trying to reference libraries in the Tools/Configure Paths/Additional Libraries folder.

Do we need to generate the xml file, even for the Additional Libraries jars that are referenced in the additionaljar directive? Will that coax B4J to display them in the class picklist?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
any library needs an xml file, it tells B4J what parameters are needed for the methods.

Does the package name /class name appear in the list of libraries on the libs tab? (it shows built in and extra libs you've added) if not then you need to have an xml file and tick the box next to the name on the libs tab.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
To get B4j to display a class in the pick list, it needs to be specifically wrapped. Even if it's just a simple pass through.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Daestrum and Steve,

Ok then, this is my problem. How are these xml files generated?

Does this mean we can't directly use external jars from the ide, unless we have the source and have generated the xml?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
To generate the xml file - you use BADoclet from inside the netbeans Eclipse IDE.
Whoops, getting the IDE mixed up.
 
Last edited:
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Thanks, Daestrum. Any alternatives to netbeans? I use Intellij.

Not familiar with these oclets. Are these variations on javadocs?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
There is a link somewhere on this site to the download location for BADoclet.
I think it's written to supply the correct output for B4J and B4A to use.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Huh. Only problem is, the link refers to an android.jar, which is part of the android sdk.

I'll try without it, and report back if any problems. These instructions might apply only to the Basic4Android product, and not B4J.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
There are two SLCs in the archive, one each for B4A and B4Jand the doclet is also included. What exactly are you trying to do? You probably don't need the #AdditionalJar: directive, as far as I know it only bundles the jar in the final jar but doesn't let you use it in any way. I've never needed it! As an example I've attached the source for jMsgboxes. You should be able to compile it with SLC.
 

Attachments

  • Msgboxes.zip
    3 KB · Views: 341
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
What am I trying to do?

I'm trying to make use of third party libraries, jars, for which the source isn't necessarily available, without decompilation.

I don't know why this is difficult to understand. We make use of third party libraries all the time, in Java & Groovy, without having to write wrappers or run it through a special processor.

If B4J doesn't have this capability yet, then ok. I'll come back, after it matures a bit more.
 
Upvote 0
Top