Native Library provides a set of Java packages are re-written in C++
- Blazing fast, small footprint with no dependency required
- Cross platform, outstanding performance with multiple-core support from STL
- Prevents nearly all memory leak and segmentation fault via automatic storage
- Packages are strictly tested with unit tests, clean with Valgrind and follow Oracle documentation
- Feel free to use in your commercial products and welcome for contributions
$ docker pull foodtiny/native:latest$ git clone https://github.com/tiny-express/native.git
$ cd native
$ cmake . -DCMAKE_BUILD_TYPE=Release
$ make native
$ sudo make install#include <native/library.hpp>
class MainApplication {
public:
static void main(Array<String> arguments) {
HashMap<String, String> hashMap;
int counter = 0;
for (String argument : arguments) {
hashMap.put("argument " + String::valueOf(counter), argument);
counter++;
}
System::out::println("We have 4 pairs:");
String pairs = "Pairs: \n";
for (Map<String, String>::Entry entry : hashMap.entrySet()) {
pairs += entry.getKey() + String(" - ") + entry.getValue() + String("\n");
}
System::out::println(pairs);
ArrayList<HashMap<String, String>> arrayList;
arrayList.add(hashMap);
System::out::println(arrayList.toString());
}
};
int main(int argc, char **argv) {
return Application(MainApplication::main, argc, argv);
}Compile your source and link with native library
$ g++ -c -o main.o HelloWorld.cpp
$ g++ -o main main.o -lnative -lstdc++
$ ./main one two threeOutput:
We have 4 pairs:
argument 3 is three
argument 2 is two
argument 1 is one
argument 0 is ./main
[{"argument 0": "./main", "argument 1": "one", "argument 2": "two", "argument 3": "three"}]More examples can be found here Support unit test by default via ApplicationTest here - Powered by C-Unit
This library provides Java classes in C++ so its syntax are friendly for both programming languages:
- Namespace - Package
// Java
System.out.println("Java");// C++
System::out::println("C++");- Array
// Java
byte[] byes = {};// C++
Array<byte> bytes = {};All data types are implemented and ready to use in C++ Application
- char - Java.Lang.Character
- byte - Java.Lang.Byte
- string - Java.Lang.String
- short - Java.Lang.Short
- int - Java.Lang.Integer
- long - Java.Lang.Long
- float - Java.Lang.Float
- double - Java.Lang.Double
- boolean - Java.Lang.Boolean
- enum - Java.Lang.Enum