Using Arduino IDE as an API I have a project where it would make a lot of sense to generate Arduino compatible source code, compile it and flash it based on some settings in the project software.

Is there any way to do this without having to rely on the user having installed the Arduino IDE/java?

The ideal would be a self-contained library that could be linked to my C/C++ program.
For compiling and uploading Arduino code, you do not need Java, nor the
Arduino IDE: you need avr-gcc, avr-libc, the Arduino core library and
avrdude. With a proper Makefile, your program just needs to

system("make upload");


C.f. the tutorial Compiling Arduino sketches using
Makefile.
On an Ubuntu or other Debian-like OS, you would just
sudo apt-get install arduino-mk make to get everything you need installed.