{"id":13693661,"url":"https://github.com/remram44/java-cpp-example","last_synced_at":"2025-04-05T02:08:30.029Z","repository":{"id":24158272,"uuid":"27548215","full_name":"remram44/java-cpp-example","owner":"remram44","description":"Example of using C++ classes from Java. Showcases SWIG, JNA and JNI","archived":false,"fork":false,"pushed_at":"2024-12-17T19:45:32.000Z","size":16,"stargazers_count":149,"open_issues_count":0,"forks_count":38,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T21:11:17.913Z","etag":null,"topics":["cpp","example","java","jna","jni","swig"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remram44.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-04T16:06:06.000Z","updated_at":"2025-03-28T15:44:16.000Z","dependencies_parsed_at":"2025-01-07T19:11:10.358Z","dependency_job_id":"cacbaa30-3940-414f-accd-2856d857a212","html_url":"https://github.com/remram44/java-cpp-example","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"695b3b9c5b1081d0e9df9a7f9197f110e30fe5c9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fjava-cpp-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fjava-cpp-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fjava-cpp-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fjava-cpp-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remram44","download_url":"https://codeload.github.com/remram44/java-cpp-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","example","java","jna","jni","swig"],"created_at":"2024-08-02T17:01:14.997Z","updated_at":"2025-04-05T02:08:30.009Z","avatar_url":"https://github.com/remram44.png","language":"CMake","funding_links":[],"categories":["CMake"],"sub_categories":[],"readme":"[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/remram44)\n\nExample of using C++ code from Java\n===================================\n\nThis repository contains three separate examples of calling a simple C++ library from Java code.\n\nThe example library doesn't do anything but contains a class, MyClass, forcing us to support C++ (and not just plain C).\n\nCMake is used to build this, since locating the dependencies got outside the range of my make-fu. The project is supposed to be portable to all major platforms.\n\nThree different wrappers are used, documented below. Each one achieves the same goal, which is using [this C++ class](cpplib/src/MyClass.cpp) from [Java code](java-jni/java/src/edu/nyu/cpptest/app/Main.java).\n\nSWIG\n----\n\nThis needs the SWIG tool: http://www.swig.org/\n\nSWIG parses the C++ header file and generates both the C++ JNI code and the Java native and helper classes.\n\nJNA\n---\n\nJNA allows Java code to use C dynamic libraries directly. Because our library is in fact C++, a small wrapper is included that wraps it as C code.\n\nYou will need the JNA jar to run this: https://github.com/java-native-access/jna\n\nJNI\n---\n\nThis examples uses JNI directly, without auto-generation. The `MyClass` class in Java code just declares its methods as being \"native\", they are provided by the dynamic library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremram44%2Fjava-cpp-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremram44%2Fjava-cpp-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremram44%2Fjava-cpp-example/lists"}