### B4J Library with Simple Library Compiler

To build Java based libraries, without usage of development environments as Eclipse, a Simple Library Compiler (SLC) is available.
More Information:
http://www.b4x.com/android/forum/threads/tool-simple-library-compiler-build-libraries-without-eclipse.29918/
Hints
• To write Java code a (simple) text editor can be used
• To learn more about Library development: http://www.b4x.com/android/forum/forums/libraries-developers-questions.32/
• To install unzip the SimpleLibraryCompiler package and run the program: LibraryCompiler creates B4A libraries and B4J_SimpleLibraryCompiler creates B4J libraries
• To include any additional files, such as .so files, in the jar then create a folder named "additional". Any file or folder inside this folder will be added to the jar file.
• To write the library code with Eclipse you need to reference Java 8 and also reference jfxrt.jar
• To run frequent during development, run SLC from the command line by a batch file
• To learn more about Javadoc go here: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
Command Line Mode
B4J_LibraryCompiler.exe
Example
For Library jRLStrings in folder c:\Daten\b4j\opensource\rolibs\jRLStrings\.
The xml and jar file are generated in the B4J additional libraries folder.
Run Command:
B4J_LibraryCompiler jRLStrings c:\Daten\b4j\opensource\rolibs\jRLStrings\
Output:
c:\Daten\b4j\ztools\SimpleLibraryCompiler>Simple Library Compiler
Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file c:\Daten\b4j\opensource\rolibs\jRLStrings\src\com\rwblinn\rl
strings\RLStrings.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, c:\Daten\b4j\ztools\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, c:\Daten\b4j\ztools\SimpleLibraryCompiler]
[-classpath, C:\Program Files (x86)\Anywhere Software\B4J\B4J.exe\../libraries\j
FX.jar;C:\Program Files (x86)\Anywhere Software\B4J\B4J.exe\../libraries\jCore.j
ar;C:\Program Files (x86)\Java\jdk8\bin\..\jre\lib\jfxrt.jar;]
[-sourcepath, src]
[-b4atarget, c:\Daten\b4j\libraries\jRLStrings.xml]
starting....
Working with class: com.rwblinn.rlstrings.RLStrings
finish: c:\Daten\b4j\libraries\jRLStrings.xml
Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***
Example Batch File 1
Echo SLC Compile
Echo For Library jRLStrings in folder c:\Daten\b4j\opensource\rolibs\jRLStrings\
Echo ---------------------------------------------------------------------------
Rem
Rem slccompiler library projectfolder
c:\Daten\b4j\ztools\SimpleLibraryCompiler\B4J_LibraryCompiler jRLStrings c:\Daten\b4j\opensource\rolibs\jRLStrings\
Rem
Pause
Example Batch File 2
Thanks to B4J Forum member stanmiller for providing this tip.
Use pushd/popd to save and restore the working directory.
This allows the user to double click and execute the .BAT from Explorer without concern to where the working directory is pathed.
Pushd changes the working directory to the folder where the .BAT is located. Then popd restores it.
@Echo Off
pushd "%~dp0"
Echo SLC Compile
Echo For Library jRLListTest in folder c:\Daten\b4\b4j\opensource\rolibs\jRLJavaList\
Echo ---------------------------------------------------------------------------
Rem
Rem slccompiler library projectfolder
c:\Daten\b4\ztools\SimpleLibraryCompiler\B4J_LibraryCompiler jRLJavaList c:\Daten\b4\b4j\opensource\rolibs\jRLJavaList\
Rem
Pause
popd
Example Batch File 3
This batch deletes the bin folder and then starts the SLC.
rd bin\classes
rd bin
c:\Daten\b4\ztools\b4jlibrarycompiler\b4j_librarycompiler.exe
Wrapping Hints
In the source code, set dependson with the external jar.
Example using external jar file bmp.jar located in the additional libraries folder.
@BA.DependsOn(values={"bmp"})
When distributing, ensure the depended library and the wrapped library are included.
Example:
jBMP180.jar depends on bmp.jar, so both needs to be distributed.

Changed: , Category: Libraries, File: T6C214M1559.htm, ID: 1559