Artistic Style has compile options for creating a shared library (DLL) or static library for use with a Graphical User Interface (GUI). The shared library can contain a Java Native Interface (JNI) and be called from a Java program. Information on compiling the various configurations of Artistic Style is in the Install Information.
Using Artistic Style as a Shared or Static Library contains information on using Artistic Style as a shared or static library. It includes a C++ sample program that can be used to test the library.
Using Artistic Style as a Java Native Interface contains information on calling Artistic Style from a Java program using the Java Native Interface. It includes a Java sample program that can be used to test the shared library. The Java Development Kit (JDK) must be installed to compile the library.
The downloads are source code files that contain a more extensive example of the sample programs.
Example2 C++ includes an AStyleInterface class that builds the option string and contains the error handling and memory allocation functions. Compile Artistic Style as a shared or static library using the macro ASTYLE_LIB. Compile Example2.cpp and AStyleInterface.cpp as an executable and link it to the library. It will format cpp files in a test directory. Artistic Style and the interface programs could also be compiled as a single executable.
Example2 Java includes an AStyleInterface class that builds the option string and contains the methods to call the shared library using the Java Native Interface (JNI). Artistic Style must be compiled as a shared library using the macro ASTYLE_JNI. Copy the shared library to the same folder as the Java class files (it is loaded from the classpath directory). It will format java files in a test-j directory.