Java Question ... has private access in ..

wl

Well-Known Member
Licensed User
Longtime User
Hi,

I'm creating a library and I was succesful in generating the library through SLC.

This is the main (simplified) Java code:

B4X:
@BA.ShortName("FakeSMTP")
@BA.Version(1.0f)
public class FakeSMTP
{
    public FakeSMTP() {
    }
}

Already when I declare variable of this type

B4X:
    Dim fk As FakeSMTP

I get:
B4X:
FakeSMTP() has private access in FakeSMTP
 

wl

Well-Known Member
Licensed User
Longtime User
Hi,

This is driving me nuts. I simplified it to:

a file called FakeSMTPServer.java in the \src subfolder of the folder to which SLC refers.

Capture.JPG


Java:
package net.wapps;
import anywheresoftware.b4a.BA;


@BA.ShortName("FakeSMTPServer")
public class FakeSMTPServer
{
    private BA ba;
    private String eventName;

    public FakeSMTPServer() {

    }

    public FakeSMTPServer Initialize(final BA ba, final String eventName) {
        this.ba = ba;
        this.eventName = eventName;
        return this;
    }
}

The library is compiled to a FakeSMTP.jar and FakeSMTP.xml in a folder to which my Additional Lubraries of my B4J environment refers.

When I write following code and compile I now get this error message:

Capture2.JPG
 
Last edited:

agraham

Expert
Licensed User
Longtime User

wl

Well-Known Member
Licensed User
Longtime User
Hi Andrew,

Moved it to \src\net\wapps and transformed the Intitialize to a void ... same result ...
 

agraham

Expert
Licensed User
Longtime User
Strange! If you post your actual library source file, just so we are definitely using the same code, I'll try it tomorrow afternoon as I'm busy in the morning. Post your compiled jar and xml for comparison as well.

EDIT: By actual I mean that cut down version that doesn't seem to work.
 

wl

Well-Known Member
Licensed User
Longtime User
Hi Andrew,

I think it has something to do with the naming of the internal files of the library. I did some renaming and I did manage to resolve the problem.

However: another problem pops up:
- SLC compiled the project (it has some external jars in the lib subfolder)
- now when I run the B4J proejct using my library I got a ClassNotFound error: it seems that the JAR file the SLC created does not include the classes I need from the external libs ?
 

wl

Well-Known Member
Licensed User
Longtime User
What internal files? You didn't mention that :mad: All you indicated was that a simple source file compiled but gave a runtime error.

Hi Andrew,

No the reason was that I simplified the setup to just one file and I see got the error. But then this was probably caused by the file structure.
Before I had a reference to other java files and I did try the file structure but it did not work.

Long story short: not sure what *exactly* was the reason but now I have another issue I won't bother you about :)

Thanks
 
Top