API Questions
NH Rao
nhrdls at gmail.com
Thu May 7 17:54:34 EDT 2026
Greetings,
I've pushed the first cut of java bindings for gnucash to
https://github.com/nhrdl/java-gnucash. This uses Java FFM and jextract to
generate the java code from various header files.
While generated code will have full API functions, java objects are not yet
complete. I am adding the corresponding functions as and when needed.
So far I was able to emulate
bindings/python/example_scripts/export_account_totals.py, the only
difference being I am not printing zero balance accounts. I've added couple
of more utilities based on my needs
On Tue, May 5, 2026 at 7:11 PM John Ralls <jralls at ceridwen.us> wrote:
> Please remember to copy the list on all replies so that everyone benefits
> from what you learn.
>
> Regards,
> John Ralls
>
> On May 5, 2026, at 17:01, NH Rao <nhrdls at gmail.com> wrote:
>
> Thank you for the reply. If you want, I can share the github link within a
> couple of days after I feel a bit more comfortable. This was my first
> forrey with Java FFM and based on what I am seeing so far, it can be very
> useful. I was able to run basic gnucash code in a day, including
> gnc_numeric which was a bit more challenging.
>
> As for the backend, I am just calling gnc_engine_init. This seems to be
> doing proper things for me like loading the file backend.
>
> I've few lofty goals in mind and will eventually start moving in that
> direction. These include getting the amount due from my PDF statements for
> various bills and creating corresponding transactions and creating splits
> for my salary stub entries.
>
> Regards,
>
> Niranjan
>
> On Tue, May 5, 2026 at 4:41 PM John Ralls <jralls at ceridwen.us> wrote:
>
>> This sounds like an interesting experiment!
>>
>> There’s nothing special about header file naming. The original XACC
>> headers had capitalized names, very few of the later ones do. Note, though,
>> that headers having the .hpp suffix export C++-mangled symbols and I don’t
>> think Java can link those without SWIG bindings.
>>
>> You’ll need at least libgnc-core-utils.so <http://core-utils.so/>, it
>> has utilities that the engine depends on. You’ll also need at least one of
>> the backend libraries to handle persistence unless you’re planning to write
>> your own.
>>
>> Regards,
>> John Ralls
>>
>>
>> > On May 5, 2026, at 1:30 PM, NH Rao <nhrdls at gmail.com> wrote:
>> >
>> > Greetings,
>> >
>> > I am experimenting with Java FFM API to call gnucash API functions. So
>> far I am able to emulate the functionality of
>> bindings/python/example_scripts/export_account_totals.py with similar
>> results. This was a just POC and now I am seriously attempting to write
>> proper code.
>> >
>> > Some questions
>> >
>> > I am using headers files which start with capital letters (e.g.
>> Account.h) as it felt like convention is to expose API from these files.
>> Did I get this right?
>> >
>> > I am just using libgnc-engine.so when importing a shared library. Do I
>> need to import any other shared libraries for the API functionality?
>> >
>> > Many functions return const char* e.g. const char * xaccAccountGetName
>> (const Account *account); but the header file does not mention that the
>> caller has to free the returned pointer. But gnc_numeric_to_string
>> explicitly mentions that the caller has to free the memory. Is it safe to
>> assume that if there is no explicit comment, I don't need to worry about
>> freeing the memory
>> >
>> > Regards,
>> >
>> > Niranjan
>> > _______________________________________________
>> > gnucash-devel mailing list
>> > gnucash-devel at gnucash.org
>> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20260507/1332d788/attachment.htm>
More information about the gnucash-devel
mailing list