65. Using Java Code
Sometimes projects require Java code to work. This code may include JAR files
or custom classes (or both). To ensure proper functionality, please follow these rules:
-
If you need to include a
JAR file
in your library, put it in thelib
directory and add a reference to the classpath (in CloverDX Designer, go to: Project properties → Java Build Path → Libraries, click ok Add JARs… and select JAR file from your${PROJECT}/lib
directory. This applies especially to libraries and connectors that users cannot inspect. However, do not bundleJAR
files that are already on the classpath, such as Bouncy Castle or certain database/JDBC drivers to avoid conflicts. -
If you need your own custom Java code to be used in the CloverDX library, put it into a proper package. The naming pattern should look like this:
com.<your company name>.libraries.<libraryName>.<className>
. The source code of the Java class should be stored in${PROJECT}/trans
directory. Java classes from this directory are compiled automatically using CloverDX Designer during development (for every Java class in each.java
file, a.class
file will be created).
-
Make sure you include all the
.class
files (compiled Java classes) in your (when exporting the library in Designer). Otherwise, the library will not be able to use the Java classes. If you use a versioning system, you may want to store the compiled classes in the repository (for example, if you use Git, do not exclude.class
files in your.gitignore
).