B4J Question Compiling Jar Library possibility to use Type/ReadB4XObject... ?

Magma

Expert
Licensed User
Longtime User
Well,

i ve decided to create a small Jar (not a b4xlib) lib but i think "that is the first time all these years" and never tried again..

Seems easy but when you have to add inline java and someway if use b4xpages turn to complicated at least for me.

What i ve done and what i want to do...

Well I am having a "class" but in class I am having a custom "Type"...
edit: According to this... I can't use type and readb4xobject at a class... ?

1) I ve noticed if having the Type inside the class not working properly... if have it in "Main" works perfect... but in main not finding the time of compiling (so ?)
B4X:
Sub Class_Globals
    Private fx As JFX
    Type MyType(TIME1 As Long, aa As String)
....

public sub mytest
            Dim mr As MyType
            mr.Initialize
            ...
            mr = raf.ReadB4XObject(raf.CurrentPosition)

2) Another thing... using some inline java ---> targeting at the "Me" - but hey! the jar i am trying to compile not a b4xpage.... so is the following going to work right ?
B4X:
                            NatMe = theMe  'theMe is an object... when call it from any app will be a b4xpage... like Me
                            NatMe.InitializeNewInstance("b4j.example.mynameofmylib.myjavaclass", Array(Null))
                            NatMe = NatMe.RunMethod("onevoidsub"...
edit: No2 works - the call is right :)

So I am stuck at (1)... Type not works as i want at my jar lib - any idea ?
 
Last edited:
Solution
For the story... I had to tell... that can't have a JAR Lib but only b4xlib..because "Type" can't be used at class with readb4xobject but only if it is in Main or other b4xpage... So for this reason using b4xlib and ask user-developer to manual insert Type and if needed by my Classes AdditionalJar...

teddybear

Well-Known Member
Licensed User
Well I am having a "class" but in class I am having a custom "Type"...

1) I ve noticed if having the Type inside the class not working properly... if have it in "Main" works perfect... but in main not finding the time of compiling (so ?)
B4X:
Sub Class_Globals
    Private fx As JFX
    Type MyType(TIME1 As Long, aa As String)
....

public sub mytest
            Dim mr As MyType
            mr.Initialize
            ...
            mr = raf.ReadB4XObject(raf.CurrentPosition)

2) Another thing... using some inline java ---> targeting at the "Me" - but hey! the jar i am trying to compile not a b4xpage.... so is the following going to work right ?
B4X:
                            NatMe = theMe  'theMe is an object... when call it from any app will be a b4xpage... like Me
                            NatMe.InitializeNewInstance("b4j.example.mynameofmylib.myjavaclass", Array(Null))
                            NatMe = NatMe.RunMethod("onevoidsub"...

So I am stuck at (1)... Type not works as i want at my jar lib - any idea ?
1.The Type inside the class has not any problem to compiling jar libray, it works properly, ,what happened when you did that?

2.myjavaclass it is a inner class, it seems to work rightly like this:
B4X:
 NatMe.InitializeNewInstance("b4j.example.mynameofmylib.myjavaclass", Array(Null))
But I think if it should work also,as below
B4X:
 NatMe.InitializeNewInstance("b4j.example.mynameofmylib$myjavaclass", Array(Null))
I don't try it yet.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Use a class and create a b4xlib out of it instead of compiling to a library.

See ExternalStorage Class. (attached)
Rename .b4xlib to .b4xlib.zip and have a look at the content. There is a CustomType in there too.
 

Attachments

  • ExternalStorage.b4xlib
    2 KB · Views: 130
Upvote 0

Magma

Expert
Licensed User
Longtime User
Thanks for your answers...

a) So there isn't compatibility with Jar Compiling when using CustomType at a Class ?
b) Or need something extra to do - if I want it to jar ?
c) at b4xlib where can I have Additionaljar or I must say developer-users-of-mylib using it... ?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
....and at b4xlib i have the same... prob... if i don't put it into class... (and lib)
and put it at the Main of project working perfect

As I can understand there is a something with jRandomAccessFile and Type but can't find what the problem is... I will return with 2 simple projects to upload and test if someone has the time... You will see the problem... Thanks in advance !
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Well created simple projects.... I am seeing that there is something with RandomAccessFile and not with Type - so at the end... i will edit the thread Title to be more helpful... at the Future... :)

I have a test.bin into objects... if accidentally delete it - you can create from working1 project uncommenting at main a small snippet-code
 

Attachments

  • working1.zip
    4.9 KB · Views: 127
  • notworking1.zip
    4.9 KB · Views: 131
Upvote 0

Magma

Expert
Licensed User
Longtime User
I can say that i can use readb4xobject... but if the Type is outside the class.... test it... with "working1" project
but why ?
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
I can say that i can use readb4xobject... but if the Type is outside the class.... test it... with "working1" project
It is not completely correct, it should be the Type is in Main or B4xMainpage module, readb4xobject will work.
See here
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Upvote 0

Magma

Expert
Licensed User
Longtime User
For the story... I had to tell... that can't have a JAR Lib but only b4xlib..because "Type" can't be used at class with readb4xobject but only if it is in Main or other b4xpage... So for this reason using b4xlib and ask user-developer to manual insert Type and if needed by my Classes AdditionalJar...
 
Upvote 0
Solution
Top